Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
319 views
in Technique[技术] by (71.8m points)

Socket.io connection url?

I have the current setup:

  1. Nodejs Proxy (running http-reverse-proxy) running on port 80.
  2. Rails server running on port 3000
  3. Nodejs web server running on port 8888

So any request starting with /nodejs/ will be redirected to nodejs web server on 8888.

Anything else will be redirected to the rails server on port 3000.

Currently Socket.io requires a connection url for io.connect.

Note that /nodejs/socket.io/socket.io.js is valid and returns the required socket.io client js library.


However, I am not able to specify connection_url to /nodejs/ on my server.

I have tried http://myapp.com/nodejs and other variants but I am still getting a 404 error with the following url http://myapp/socket.io/1/?t=1331851089106

Is it possible to tell io.connect to prefix each connection url with /nodejs/ ?

question from:https://stackoverflow.com/questions/9729308/socket-io-connection-url

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

As of Socket.io version 1, resource has been replaced by path. Use :

var socket = io('http://localhost', {path: '/nodejs/socket.io'});

See: http://blog.seafuj.com/migrating-to-socketio-1-0


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...