Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSL Web Socket Error: stream truncated #915

Closed
svmakarov opened this issue Nov 30, 2017 · 6 comments
Closed

SSL Web Socket Error: stream truncated #915

svmakarov opened this issue Nov 30, 2017 · 6 comments

Comments

@svmakarov
Copy link

svmakarov commented Nov 30, 2017

Hello.

I investigate boost.beast library to host web socket services in my c++ app.
I try with two examples from beast library: websocket_server_sync.cpp and websocket_server_sync_ssl.cpp.

Without SSL web socket works correctly.
But if I run SSL web socket I get following error:
Error: stream truncated

It occurs during ws.accept().

Could you please explain what the possible reason of such behavior?

BOOST_BEAST_VERSION 124

As client I use simple JavaScript:

<script> var socket = new WebSocket("wss://127.0.0.1:8080"); socket.onopen = function() { socket.send("HelloWS"); }; socket.onclose = function(event) {}; socket.onmessage = function(event) {}; socket.onerror = function(error) {}; </script>
@vinniefalco
Copy link
Member

Try using different browsers. I have noticed that some browsers work and others don't. I believe it has something to do with the self-signed certificates that the beast examples use.

@vinniefalco
Copy link
Member

Anyway "stream truncated" means that the other end closed the connection abruptly. Chrome does this often, it usually never performs the SSL closing handshake. Google says that behavior leads to better performance.

@svmakarov
Copy link
Author

I try to open in three different browsers, results is following:

Firefox: Error: tlsv1 alert unknown ca
Chrome: Error: stream truncated
Opera: Error: stream truncated

All errors occurs during ws.accept().

Which browser do you use for this examples, or this problem specific for different machine and OS?

@vinniefalco
Copy link
Member

Microsoft Edge browser worked for me. Chrome and Firefox did not.

@svmakarov
Copy link
Author

The problem was connected with self signed certificate.

All works fine if in Firefox I add my server (localhost:8080) to Server Exception in Certificate Manager.

And also I have tried to run ssl server with my certificate which is not self signed and which has correct Common Name (CN) = localhost and has correct Subj Alt Name = localhost. With my certificate SSL Web Sockets server works correctly in all browsers.

Many thanks for your quick replies.

@vinniefalco
Copy link
Member

Glad to hear that you got it sorted! SSL certificates are a hassle...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants