Hi,
I have a similar problem and I don't know if I'm doing something wrong or if it's a bug.
I have a client on iOS that sends a UDP message to a server programmed in Java.
Once the server receives the message it responds with a UDP message. The client gets the message and all is well.
But when I run the following scenario, I get an error message:
1. I start the client and an instance of NWConnection is created.
2. the connection is started with connection.start(...)
3. directly after the start I execute the command: connection.receiveMessage(...)
4. the server is NOT started
5. the created NWConnection is in "Ready" state
6. i send a message
7. the passed "NWConnection.SendCompletion" is called without error. Otherwise nothing happens here. No errors.
8. i start the server
9. i send a message again
10. the message arrives at the server. Then the server sends a UDP response.
11. On the client I now get the following message in the console = "2021-04-10 12:30:43.660695+0200 MySocketClient[27462:5157187] [connection] nw_read_request_report [C1] Receive failed with error "Connection refused""
12. my response handler is called "(data: Data?, context: NWConnection.ContentContext?, isComplete: Bool, error: NWError? )". Interestingly, I get an error = POSIXErrorCode: Connection refused. But at the same time data contains the correct content sent by the server.
13. If I now send further messages from the client to the server everything runs as described from step 6 to step 12.
Am I doing something wrong here? If not, maybe my description can help.