socket.io 问题使用sails.js [英] socket.io issue using sails.js

查看:57
本文介绍了socket.io 问题使用sails.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 socket.io 与sails js 一起使用.我知道它非常简单,并且sails 提供了一个开箱即用的socket.io 结构.然而,当我尝试使用

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返回 0 == str.indexOf('s:')^类型错误:无法调用未定义的方法indexOf"

/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?

谢谢!

推荐答案

看起来您在 io.connect() 调用中缺少一些引号,但我无法想象您的客户端应用程序不会抛出语法如果你的代码真的是这样写的,就会出错.确认您已获得:

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');

这篇关于socket.io 问题使用sails.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆