U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » U++ MT-multithreading and servers » Websocket issue
Websocket issue [message #61956] Tue, 24 March 2026 12:16 Go to previous message
przem_kaz is currently offline  przem_kaz
Messages: 10
Registered: April 2010
Location: Poland
Promising Member
Hi, upp community
I don't know if it's just my lack of experience, but I'm planning to build an app to communicate with a device that uses WebSocket to send events.

During testing, I noticed that my test app isn't establishing a connection correctly, even though the same connection works fine when using tools like Postman or Insomnia.
So I tested the connection with the most popular WebSocket test server: wss://echo.websocket.org.
And here, too, my app throws an error.
Code below.
#include <Core/Core.h>

using namespace Upp;

CONSOLE_APP_MAIN
{
	StdLogSetup(LOG_COUT|LOG_FILE);
	
	WebSocket::Trace();

		WebSocket ws;
		ws.Trace();
		LOG(GetSysTime());
		LOG(ws.GetHeaders());
		//ws.NonBlocking();		
		ws.Connect("wss://echo.websocket.org");
		if(ws.IsError()) {
			LOG("Failed to connect");
			LOG(ws.GetError());
			LOG(ws.GetErrorDesc());
			return;
		}
		Sleep(1000);
		LOG(GetSysTime());
		ws.SendText("010203");
		Sleep(1000);
		LOG("Response: ");
		LOG(ws.Receive());
		
		ws.Close();

}
Below is the log output:
03/24/2026 12:11:20
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: cs,en-US;q=0.7,en;q=0.3
Sec-WebSocket-Version: 13
Sec-WebSocket-Extensions: permessage-deflate
Connection: keep-alive, Upgrade
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket

WS CLIENT DNS resolved
WS CLIENT Connect issued
WS CLIENT Blocking SSL handshake finished
WS CLIENT Sending connection request
WS CLIENT ERROR: Socket has been closed unexpectedly
Failed to connect
socket(668) / SSL handshake: SSL_ERROR_SSL; error:0A000126:SSL routines::unexpected eof while reading
socket(668) / SSL handshake: SSL_ERROR_SSL; error:0A000126:SSL routines::unexpected eof while reading

Can someone check if the SecureWebSockets implementation in UPP is working properly?

Thanks in advance for your help and advice

Best regards
Przemek

[Updated on: Tue, 24 March 2026 12:16]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Can't use MT to capture console output
Next Topic: Https refarance example doesn't work
Goto Forum:
  


Current Time: Sun Apr 26 19:41:26 GMT+2 2026

Total time taken to generate the page: 0.00639 seconds