NathanaelA/nativescript-websockets

Connection cancels on iOS after upgrade to tns 5.X

Adelrisk opened this issue · 6 comments

EDIT: see below for an update of a further investigation. tl;dr: The problem is caused by a number of as-yet-unknown app specific dependencies and/or code, in addition to Nativescript 5.X.

A low-level error is preventing me from upgrading an existing app to Nativescript 5, which causes me to contemplate questions.

After upgrading from Nativescript 4.2 to 5 (and again recently 5.2), everything in the app appears to work as before, except a new behaviour occurs when using the Websockets: they cancel unexpectedly without explanation.

TCP Conn 0x2809af900 canceled
[C2 Hostname#88d08305:443 tcp, legacy-socket] cancel
[C2 Hostname#88d08305:443 tcp, legacy-socket] cancelled
[C2.1 <private> 192.168.178.111:51863<->IPv4#02d701df:443]
Connected Path: satisfied (Path is satisfied), interface: en0, ipv4, ipv6, dns
Duration: 2.064s, DNS @0.001s took 0.002s, TCP @0.004s took 0.034s
bytes in/out: 3931/1022, packets in/out: 8/6, rtt: 0.045s, retransmitted packets: 0, out-of-order packets: 0
0.000s [C2 <private> Hostname#88d08305:443 resolver] path:start
0.000s [C2 <private> Hostname#88d08305:443 resolver] path:satisfied
0.001s [C2 <private> Hostname#88d08305:443 resolver] resolver:start_dns
0.003s [C2 <private> Hostname#88d08305:443 resolver] resolver:receive_dns
0.003s [C2.1 <private> 192.168.178.111:51863<->IPv4#02d701df:443 socket-flow] path:start
0.004s [C2.1 <private> 192.168.178.111:51863<->IPv4#02d701df:443 socket-flow] path:satisfied
0.004s [C2.1 <private> 192.168.178.111:51863<->IPv4#02d701df:443 socket-flow] flow:start_connect
0.037s [C2.1 <private> 192.168.178.111:51863<->IPv4#02d701df:443 socket-flow] flow:finish_connect
0.038s [C2 <private> Hostname#88d08305:443 resolver] flow:finish_connect
0.038s [C2.1 <private> 192.168.178.111:51863<->IPv4#02d701df:443 socket-flow] flow:changed_viability
0.038s [C2 <private> Hostname#88d08305:443 resolver] flow:changed_viability
2.064s [C2] path:cancel
nw_endpoint_flow_protocol_disconnected [C2.1 IPv4#02d701df:443 cancelled socket-flow (null)] Output protocol disconnected
nw_connection_report_state_with_handler_locked [C2] reporting state cancelled

This occurs very consistently and reproducibly, and does not happen when I don't upgrade Nativescript. Any clues how I might make progress on this problem?

UPDATE:

  • I upgraded the demo to Nativescript 5.2 and could not reproduce the problem or find any problems. See here for my changes. I guess this is still good news?
  • I connected my app to your demo server to eliminate the server as a source of errors. It received the init/hello messages and spontaneously cancelled soon after, so no observable difference.
  • the new Nativescript option discardUncaughtJsExceptions didn't catch any errors.
  • adding/removing a websocket protocol didn't change the errorful behaviour.

This problem exists for version 1.5.1 and 1.5.3.

Btw, there is no propagation of an error by the Nativescript instance. No callbacks are triggered and no (Javascript) error is reported.

@Adelrisk @NathanaelA the same for me 👆

Thank you for reporting the issue. Just to set the expectation; Unfortunately, I have like zero unpaid free time right now to investigate why it is not working at this point. All my "unpaid" time is currently going to several other projects that I am currently trying to finish.

If someone's company wants to sponsor the time to fix this (send me an email) -- or if anyone wants to trace down the issue, I will gladly take PR's. Otherwise it will probably be at least a few weeks before I might have any time to look into this issue.

any news on this?
we're now on tns v6.3.3 - and this just happend...

#82 kinda solves this by using ios native sockets - which are availabe from ios 13 on.

I basically merged your PR into v2.0, however I did ALSO test PocketSocket on iOS 14.7 and had no issues with NS v8.0