Reputation: 339
I have a Java WebSocket API using this library and a Swift iOS WebSocket client in my application using the Starscream library. When I test my Java server with WebSocketKing it works perfectly. When I test my Swift iOS client with ws://echo.websocket.org
as the host it also works perfectly. But when I try to connect my client to my server using host localhost:5001
(or any other port like 8080) I get this error:
nw_socket_handle_socket_event [C2.1:1] Socket SO_ERROR [61: Connection refused]
I can't find anything online that has helped me track down why my server and client can't talk to each other. There is no authentication going on yet. nc -v localhost 5001
provides this message:
Connection to localhost port 5001 [tcp/commplex-link] succeeded!
So I officially have no idea wtf is going on lol. Any ideas?
Upvotes: 0
Views: 1088
Reputation: 339
Just realized my mistake: I was using a physical device as the simulator, which was trying to connect to "localhost:5001", which doesn't exist for the iPhone's localhost. I'm going to have to host this websocket server on AWS or something to test it out.
Upvotes: 1