Socket.io在Android chrome 51上不起作用 [英] Socket.io doesn't work on android chrome 51

查看:61
本文介绍了Socket.io在Android chrome 51上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Socket.io可以在台式机chrome,chrome和firefox上完美运行,但在chrome(标准版和dev(51)安卓版)上均不能正常运行.

Socket.io works flawlessly on desktop chrome, chromium and firefox, but not on chrome for android both standard and dev(51).

这是我的代码:

index.html:

index.html:

<script src="/socket.io/socket.io.js"></script>
<script type="text/babel" src="scripts/messenger.js"></script>

messenger.js

messenger.js

var socket = io.connect('localhost:3000');
socket.on('chat message incoming', (msg) =>
        this.incomingMessageHandler(JSON.parse(msg))
    )
socket.emit('chat message outgoing', JSON.stringify(message));

我已经完全按照官方的socket.io教程进行了所有操作.有什么想法吗?

I've done everything exactly as in official socket.io tutorial. Any ideas what's going on?

干杯,Wojtek

推荐答案

好吧,看来您正在连接到 localhost:3000 ,它可能未指向手机上的有效NodeJS服务器.尝试将该地址更改为可运行您的应用程序的有效地址.另外,最好将协议( http://)添加到地址.

Well, it looks like you are connecting to localhost:3000, which might not point to a valid NodeJS server on your phone. Try changing that address to a valid address which has your application running. Also, it's preferable to add the protocol (http://) to the address.

这篇关于Socket.io在Android chrome 51上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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