So I've built a Node.Js (version 0.4.7) application using Express (version 2.3.3) and Socket.io (version 0.6.17) for websockets. Everything works fine on my local machine with the same setup, but when I set it up on my server the socket on the client side is unable to communicate with the server. More specifically I get this error as it tries to use each transport method unsuccessfully:

GET http://mysite.com/socket.io/xhr-polling//1304563260398 undefined (undefined)

Everything else works, and I'm sure I setup the custom apps correctly and am using the assigned port 47556. I'm at a loss for what to do and heard that it may have something to do with nginx, but I'm not sure.

Any help would be massively appreciated since I've been at this for hours.

asked 04 May '11, 21:55

gisborne's gravatar image

gisborne
815
accept rate: 0%

edited 04 May '11, 21:56


Hi,

Websockets require a keepalive connection which is not possible through Nginx as it only supports HTTP 1.0 connections to the backend.

So, to use Websockets you need to bypass nginx which can only be done if you have a dedicated IP and get the port where your app is listening is opened by us for incoming connections.

You can apply for a dedicated IP here(it costs $5/month): https://my.webfaction.com/upgrades

Hope that helps!

link

answered 04 May '11, 22:04

neeravk's gravatar image

neeravk
1.5k1411
accept rate: 41%

Great, so my intuition was close. If I get the dedicated IP, will things just work or do I need to configure nginx?

(04 May '11, 22:12) gisborne gisborne's gravatar image

You would just need to get any port(depending upon availability) opened on the dedicated IP and bind your server to that on the IP.

You won't need to configure Nginx.

(04 May '11, 22:18) neeravk neeravk's gravatar image

Update: As of now, you don't need a dedicated IP to get ports opened. You can just request it in a support ticket and we can open it on a shared IP specifically added to servers for opening ports.

(16 May '12, 02:39) neeravk neeravk's gravatar image

What kind of traffic is allowed on the opened port? It used to be allowed only the above mentioned HTTP 1.0, and now?

(16 May '12, 06:16) unstar unstar's gravatar image

Any kind of TCP and UDP traffic is allowed.

(16 May '12, 06:43) iliasr ♦♦ iliasr's gravatar image

Awesome! :)

(16 May '12, 07:19) unstar unstar's gravatar image

Just an update: you now no longer need a dedicated IP for this -- our servers now have secondary shared IP addresses for this purpose, so just open a support ticket and let us know the name of the Custom Application (listening on port) for which we should open the port in the firewall.

(13 Oct '13, 01:48) ryans ♦♦ ryans's gravatar image
showing 5 of 7 show 2 more comments
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×32
×12
×9

Asked: 04 May '11, 21:55

Seen: 3,119 times

Last updated: 13 Oct '13, 01:48

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited