zwopple / PocketSocket

Objective-C websocket library for building things that work in realtime on iOS and OS X.
Other
414 stars 129 forks source link

Not working with Firefox client #34

Closed AndreiArdelean1 closed 8 years ago

AndreiArdelean1 commented 9 years ago

Firefox sends the a header with the "Connection" "keep-alive, Upgrade", which does not pass: + (BOOL)isWebSocketRequest:(NSURLRequest *)request

from PSWebSocketDriver.m The problem is at line (line 87): [[headers[@"Connection"] lowercaseString] isEqualToString:@"upgrade"]

After replacing it with [[headers[@"Connection"] lowercaseString] containsString:@"upgrade"] or [[[[headers[@"Connection"] lowercaseString] stringByReplacingOccurrencesOfString:@" " withString:@""] componentsSeparatedByString:@","] containsObject:@"upgrade"]

the WebSocket opens and then fails with error :

Error Domain=PSWebSocketErrorDomain Code=3 "Output stream end encountered" UserInfo={NSLocalizedDescription=Output stream end encountered}

but the stream is actually of class NSInputStream.

Can anyone provide some suggestions?

AndreiArdelean1 commented 9 years ago

Aparently "Sec-WebSocket-Extensions" "permessage-deflate", PocketSocket and Firefox do not work well together. I ended up disabling it in the server implementation.

arsinio commented 8 years ago

For anyone that may be encountering this problem, here's a clarification of @AndreiArdelean1's method:

PSWebSocketDriver.m:87 Replace [[headers[@"Connection"] lowercaseString] isEqualToString:@"upgrade"] with [[headers[@"Connection"] lowercaseString] containsString:@"upgrade"]

PSWebSocketDriver.m:113 Replace _pmdEnabled = YES; with _pmdEnabled = NO;

robertjpayne commented 8 years ago

To be fair Firefox is against spec here, there should be nothing but 'upgrade' in that header. However, I've pushed a fix to develop though I'm still working on getting the test suite back up and running so not 100% sure it's good to go yet.