Xojo.Net.HTTPSocket Bug or Oversight

I am trying to establish a WebSocket connection using Xojo.Net.HTTPSocket. No matter what I do, the socket keeps raising its Error event with the following Xojo.Net.NetException:

ErrorDomain: NSURLErrorDomain ErrorNumber: -1002 Message: unsupported URL UnderlyingError.ErrorDomain: kCFErrorDomainCFNetwork

This is happening will any and all WebSocket connection attempts such as: wss://echo.websocket.org.

Yes I have correctly set the request headers. I’m worried that there’s an oversight on Xojo’s part in that the Xojo.Net.HTTPSocket class only allows http and https protocols. If so, this is a massive bug as it effectively makes it impossible to use WebSockets on iOS. It also makes it buggy to use on desktop as the classic framework SSLSocket only supports HTTP 1.0 which does not correctly interface with many WebSocket servers.

This is an example of trying to make the Send request (I have tried with and without setting any request headers with no success):

Dim MySocket As New Xojo.Net.HTTPSocket MySocket.Send("GET", "wss://echo.websocket.org")

Appending the port does nothing:

MySocket.Send("GET", "wss://echo.websocket.org:443")

Can anyone help at all?

The http protocol is not the same as websocket, and the HTTPSocket doesn’t speak it. You’ll need to start with a Xojo.Net.TCPSocket, create a simple http protocol just for the negotiation and work from there.

Xojo.Net.TCPSocket isn’t available on desktop or console though right?

The only other WebSocket implementation out there for Xojo is Kem’s WebSocket class (based on the classic SSLSocket) and that will never work properly on desktop because it is HTTP 1.0

Tim Dietrich Supports WebSockets from his Aloe Express
https://aloe.zone/resources/tech-notes/using-websockets.html

Maybe you can ask him?

[quote=408004:@Oliver Osswald]Tim Dietrich Supports WebSockets from his Aloe Express
https://aloe.zone/resources/tech-notes/using-websockets.html

Maybe you can ask him?[/quote]
Aloe is based on the SSLSocket and the ServerSocket. Both of which are classic framework and don’t support HTTP 1.1.

[quote=407997:@Garry Pettet]Xojo.Net.TCPSocket isn’t available on desktop or console though right?

The only other WebSocket implementation out there for Xojo is Kem’s WebSocket class (based on the classic SSLSocket) and that will never work properly on desktop because it is HTTP 1.0[/quote]
Actually either will work, since you’d need to make the http connection yourself anyway.

I think you’re confusing where the http 1.1 protocol is though. Most web servers that support 1.1 will also support 1.0, especially for this sort of transaction.

Have you tried Kem or Tim’s classes?

I’ve moved this discussion to this thread:

https://forum.xojo.com/50276-websockets/0#p408012

As it’s essentially a duplicate.