socket.io issue using sails.js

走远了吗. 提交于 2019-12-13 02:22:06

问题


I am trying to use socket.io with sails js. I understood that it was pretty straighforward and that sails provided an available socket.io structure out of the box. Howeve When I try to connect to my sails server from a distant client using

io.connect(http://localhost:1337)

It makes my server crash with the message:

/node_modules/express/node_modules/connect/lib/utils.js:216 return 0 == str.indexOf('s:') ^ TypeError: Cannot call method 'indexOf' of undefined

I am probably missing something but I don't understand what.... Any clue about this?

Thanks !


回答1:


Looks like you're missing some quotes in your io.connect() call, but I can't imagine that your client app wouldn't throw a syntax error if your code really was written like that. Verify you've got:

io.connect('http://localhost:1337');



回答2:


ahem... Did you had a look @ the doc : http://sailsjs.org/#!documentation/sockets this is quite self explanatory, but if you need any help



来源:https://stackoverflow.com/questions/18444155/socket-io-issue-using-sails-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!