在建立连接之前“WebSocket是关闭的”是什么意思? [英] What does "WebSocket is closed before the connection is established" mean?

查看:534
本文介绍了在建立连接之前“WebSocket是关闭的”是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JavaScript和联盟平台我将如何诊断此问题?非常感谢。

I'm using JavaScript and the Union platform How would I go about diagnosing this problem? Many thanks.

推荐答案

如果你去 http://jsbin.com/ekusep/6/edit 并查看JavaScript控制台,您将看到在建立连接之前WebSocket已关闭已记录。我在Chrome中对此进行了测试。

If you go to http://jsbin.com/ekusep/6/edit and view the JavaScript console you'll see the 'WebSocket is closed before the connection is established' logged. I've tested this in Chrome.

在此代码中,含义是 ws.close()是在连接被提供机会之前调用(通过用户代码)。

In this code what it means is that ws.close() was called (by user code) before the connection was even given a chance to be established.

因此,此错误的原因是代码尝试关闭WebSocket连接之前它有机会实际连接。

So, the cause of this error is if code attempts to close the WebSocket connection before it's had a chance to actually connect.

这篇关于在建立连接之前“WebSocket是关闭的”是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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