![](/img/trans.png)
[英]chrome extension WebSocket connection to 'ws://localhost:9090/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
[英]WebSocket connection to 'wss://ip:8080/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
var FancyWebSocket = function(url)
{
var callbacks = {};
var ws_url = url;
var conn;
this.bind = function(event_name, callback){
callbacks[event_name] = callbacks[event_name] || [];
callbacks[event_name].push(callback);
return this;// chainable
};
this.send = function(event_name, event_data){
//this.conn.send(event_data);
this.conn.onopen = () => this.conn.send(event_data);
return this;
};
this.connect = function() {
if ( typeof(MozWebSocket) == 'function' )
this.conn = new MozWebSocket(url);
else
this.conn = new WebSocket(url);
// dispatch to the right handlers
this.conn.onmessage = function(evt){
dispatch('message', evt.data);
};
this.conn.onclose = function(){dispatch('close',null)}
this.conn.onopen = function(){dispatch('open',null)}
};
this.disconnect = function() {
this.conn.close();
};
var dispatch = function(event_name, message){
if(message == null || message == "")
{
}
else
{
video(message);
}
}
};
var Server;
function send( text )
{
Server.send( 'message', text );
}
$(document).ready(function(){
Server = new FancyWebSocket('wss://103.211.219.27:8080');
Server.bind('open', function()
{
});
Server.bind('close', function(data)
{
});
Server.bind('message', function(payload)
{
});
Server.connect();
});
这是我之前被问到但没有得到任何答案的问题。 在这段代码中,我正在通过 IP 和端口构建视频直播,但出现错误,即
WebSocket 连接到“wss://ip:8080/”失败:连接建立错误:net::ERR_CONNECTION_REFUSED
我不知道为什么会这样。 我已经拥有我的域的 SSL 这就是为什么我使用wss
但我仍然有同样的问题。 我的控制台中总是出现此错误this.conn = new WebSocket(url);
. 那么,如何通过 websocket 建立成功连接? 请帮我。
谢谢你
在 jquery 替换
服务器 = 新的 FancyWebSocket('ws://103.211.219.27:8080')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.