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();
});
This is my previous question as I was asked but not getting any answer. In this code I am building video live streaming through IP and Port but I am getting error ie
WebSocket connection to 'wss://ip:8080/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
I don't know why this is occurring. I have already have SSL of my domain that's why I am using wss
but still I have same problem. I always got this error in my console on line this.conn = new WebSocket(url);
. So, How can I establish successful connection through websocket? Please help me.
Thank You
In jquery replace
Server = new FancyWebSocket('ws://103.211.219.27:8080')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.