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

问题描述

我正在使用 JavaScript 和 Union 平台 我将如何诊断这个问题?非常感谢.

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 在建立连接之前关闭"?意思是?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 23:44