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

WebSocketException: Not GET request #104

Open
qblook opened this issue Mar 26, 2017 · 7 comments
Open

WebSocketException: Not GET request #104

qblook opened this issue Mar 26, 2017 · 7 comments

Comments

@qblook
Copy link

qblook commented Mar 26, 2017

Hello! I have a next exception when client try to connect to listener by wss:

Api.Hubs.Private.WebSocket.WebSocketHubPrivate+<AcceptWebSocketClientAsync>c__async0: WebSocket Stop accepting clients vtortola.WebSockets.WebSocketException: Not GET request
  at vtortola.WebSockets.WebSocketHandshaker.ParseGET (System.String line, vtortola.WebSockets.WebSocketHandshake handshake) [0x0001f] in <3efbcd29638a4658ba36943efbb4aba5>:0 
  at vtortola.WebSockets.WebSocketHandshaker.ReadHttpRequest (System.IO.Stream clientStream, vtortola.WebSockets.WebSocketHandshake handshake) [0x0001a] in <3efbcd29638a4658ba36943efbb4aba5>:0 
  at vtortola.WebSockets.WebSocketHandshaker+<HandshakeAsync>d__0.MoveNext () [0x00043] in <3efbcd29638a4658ba36943efbb4aba5>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <8f2c484307284b51944a1a13a14c0266>:0 
  at vtortola.WebSockets.WebSocketListener+<AcceptWebSocketAsync>d__4.MoveNext () [0x000be] in <3efbcd29638a4658ba36943efbb4aba5>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0 
  at Api.Hubs.Private.WebSocket.WebSocketHubPrivate+<AcceptWebSocketClientAsync>c__async0.MoveNext () [0x000d4] in <7cc61b8be3914d60aa0c0c7123236ba4>:0 

Code for creating listener was used from examples.
SSL feature enabling code:

var options = new WebSocketListenerOptions () {
  NegotiationQueueCapacity = Convert.ToInt32(ConfigurationManager.AppSettings["Api.Notifications.Private.WebSocket.NegotiationQueueCapacity"]),
  ParallelNegotiations = Convert.ToInt32(ConfigurationManager.AppSettings["Api.Notifications.Private.WebSocket.ParallelNegotiations"]),
  SubProtocols = new [] { "text" }
			};

server = new WebSocketListener (endpoint, options); 
var rfc6455 = new vtortola.WebSockets.Rfc6455.WebSocketFactoryRfc6455 (server);
server.Standards.RegisterStandard (rfc6455);


var certPath = ConfigurationManager.AppSettings ["Api.Notifications.Private.WebSocket.Certificate.File"].ToString();
var certPass = ConfigurationManager.AppSettings ["Api.Notifications.Private.WebSocket.Certificate.Password"].ToString();
certificate = new X509Certificate2(certPath, certPass);

server.ConnectionExtensions.RegisterExtension (new WebSocketSecureConnectionExtension (certificate));

Thank You in advance!
// alex

@vtortola
Copy link
Owner

Hi,

Is it a self-signed certificate? Does it work when you use it with HTTPS?

Cheers.

@qblook
Copy link
Author

qblook commented Mar 27, 2017

Hello,

yes, this is a self-signed certificate. Apache httpd ssl working with this sertificate (converted to pem/key). For Web-Socket hub in the project i use pfx (p12) format and password.

// sincerely, alex

@vtortola
Copy link
Owner

The browser needs the user to accept that certificate, are you using it for HTTPS as well in the same page that is initiating the WebSocket connection?

@qblook
Copy link
Author

qblook commented Mar 27, 2017

Yes, in opening the page browser (chrome) write about self-signed certificate ( and allow to select "Continue with this certificate..". I press it and continue to working with page.
But web-socket can't connect until i open this connection (wss://....) address directly in web-browser and select again "Continue with this certificate.., and only after it and reloading page web-socket connection is established and in status 101. But in the server logs still have this exception - "Not GET Request" :(
And as result - can't send notifications by web-socket chanel from server to client

// sincerely, alex

@vtortola
Copy link
Owner

@qblook
Copy link
Author

qblook commented Mar 27, 2017

Yes, i convert *.pem certificate to *.p12 using openssl unix-utility

But now i see that it's working without any problems if i use not self-signed certificate.. So it can be certificate problem. For converting normal certificate i have used same way.

It's possible if problem with certificate, WebSocketLibrary have a wrong request string?
And throw this exception:
https://github.com/vtortola/WebSocketListener/blob/master/vtortola.WebSockets/Http/WebSocketHandshaker.cs#L179

// sincerely, alex

@netvillage
Copy link

fyi. I get this when my certificate expires

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

3 participants