Question
Socket.io connection timing out
I’ve made a small application that has a chat feature using node.js + socket.io to communicate. It works perfectly on my local ubuntu machine but I can’t seem to getting working on my droplet. The websocket communication just times out.
I’ve tried following multiple tutorials including http://nginx.com/blog/nginx-nodejs-websockets-socketio/ to no avail. I’ve spent two days so far on this. Any help would be greatly appreciated.
The app is written using the php framework Laravel, and node.js + socket.io is being used on the back end. The /etc/nginx/sites-available/default file is as below by default: (I have reverted all my attempts at fixing the problem)
server {
listen 80 defaultserver;
servername default;
root /home/forge/default/public;
# FORGE SSL (DO NOT REMOVE!)
# ssl_certificate;
# ssl_certificate_key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/default-error.log error;
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_param APP_KEY "SomeRandomString";
fastcgi_param APP_DEBUG "true";
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×
Were you ever able to find a solution? I’m having the same issues.
Hey @kevnk,
the solution had to do with setting up the ports required for the communication.
By default, all ports except :80 are blocked.
I’m sorry, but it’s been too long for me to remember the specifics.