hi , I used ubuntu(12.04) + nodejs (v0.10.22) + socket.io (v0.9.14) to transmit messages.

There are ~300 simultaneous connections. After some hours (about 1 or 2 hours above, it doesn't show up immediately), some connections will persistent in the state CLOSE_WAIT or FIN_WAIT2.

And these un-dead connections grows linearly with time. The users will hard to connect socket server when the connections number reach the limit (Default 1024 - see also Linux TCP/IP tuning for scalability) , unless some connections released normally.

The following was socket service connections status, running about 3 hours.

## Probably Solutions

### 1. Touch js file in regular periods

Using Nodemon Package to run js file, when change the file's last modified time, nodemon will restart service, and release all previous un-dead connections (CLOSEWAIT or FINWAIT2)

### 2. Increase connections limit

Try to let connections hard to reach limit.

### 3. Decrease keep-alive timeout

Let operation system to close connections automatically in the short time, but I'm not try it yet.

## Question

I found some probably solution to fix the problem. But the above solutions were not really solved the persistent connections with state CLOSE_WAIT or FIN_WAIT2 problem. I could find this is a result of server(CLOSE_WAIT) or clients (FIN_WAIT2) not correctly closing connections. I think socket.io will force-close these incorrectly connection after some timeout. But it seems like not work correctly.

I try to reappear the state CLOSE_WAIT or FIN_WAIT2 problem in my test environment. But it never show up these connection situation.

1. After connect socket server and disconnect network
2. Connect socket server for a long time

I found @njam ask related question before (Many stale connections in state CLOSE_WAIT and FIN_WAIT2), but still can't find the solution. Does anyone know how to solve this problem??

Thanks

## References

1. Many stale connections in state CLOSE_WAIT and FIN_WAIT2
2. TIME_WAIT and its design implications for protocols and scalable client server systems
3. Using TCP keepalive under Linux
4. Linux TCP/IP tuning for scalability

## PHP ARTISAN MIGRATE指令

### migrate指令用途

migration 執行尚未執行的migration
migrate:install 在資料庫建立migration管理資料表
migrate:make 建立新的migration檔案
migrate:refresh 重設資料庫所有的migration，並重新執行所有的migration
migrate:reset 重設資料庫所有的migration
migrate:rollback 復原最後一筆migration紀錄
app/config/app.php檔案中你會找到一組key的位置，這個key是一組32個字元的key，我們可以自己輸入想要的key，或者使用Laravel 4提供的Artisan命令列去自動亂數產生一組key