WebSocket problem

Hi all!

I have problem after disconnection the socket server.

Application still work, but I see message box of microsoft visual c++ runtime library"

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information

In output console I see:

JS: onopen

connection closing..
JS: onclose

First-chance exception at 0x00b2bdad in BG.exe: 0xC0000005: Access violation reading location 0xfeeefeee.
Invalid parameter passed to C runtime function.
Invalid parameter passed to C runtime function.
The thread 'Win32 Thread' (0x130c) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x1abc) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x118c) has exited with code 0 (0x0).

After click “OK” in messagebox - application closes:

The program '[3216] BG.exe: Native' has exited with code 3 (0x3).

Event working correctly, but I getting error after event.

JS code:

Network.socket = new WebSocket("ws://g.ro:21");
Network.socket.onopen = function(evt) {
		log('onopen');
};
Network.socket.onclose = function(evt) {
		log('onclose');
};
Network.socket.onerror = function(evt) {
		log('onerror');//NEVER SEEN!
};

Somehow possible to handle errors to work with sockets?

There’s a bug in WebSocket.cpp. Fix like below:

#include <iostream>
#include <sstream>

        std::stringstream ss;
		ss << _port;        
        std::string hostWithPort = _host+":"+ss.str();
        
        _wsInstance = libwebsocket_client_connect(_wsContext, _host.c_str(), _port, _SSLConnection,
                                             _path.c_str(), hostWithPort.c_str(), _host.c_str(),
                                             name.c_str(), -1);

Thanks. But no difference in result :frowning:

With uncommented CCLOG in WebSocket::onSocketCallback:

socket callback for 4 reason
connection closing..
JS: onclose

socket callback for 21 reason
First-chance exception at 0x00fe346e in BG.exe: 0xC0000005: Access violation reading location 0xfeeefeee.
Invalid parameter passed to C runtime function.
Invalid parameter passed to C runtime function.