Skip to content

WebSocket Fails To Reconnect When Internet Is Disconnected Then Restored #3498

@oolabib

Description

@oolabib

Summary

In a legacy project I'm stuck with version 0.53.0 of Apollo-iOS.

I noticed once thing, the subscription is not restored when it's disconnected initially. I even tried manually disconnecting and reconnecting but in vain.

Here's

nw_connection_get_connected_socket_block_invoke [C24] Client called 
nw_connection_get_connected_socket on unconnected nw_connection
TCP Conn 0x60000332e080 Failed : error 0:50 [50]
"websocket is disconnected: Error Domain=NSPOSIXErrorDomain Code=50 \"Network is down\" UserInfo={_kCFStreamErrorCodeKey=50, _kCFStreamErrorDomainKey=1}"

Version

0.53.0

Steps to reproduce the behavior

I disconnected the device from internet, landed on a screen where a subscription is fired. The subscription failed with these errors.

nw_connection_get_connected_socket_block_invoke [C24] Client called 
nw_connection_get_connected_socket on unconnected nw_connection
TCP Conn 0x60000332e080 Failed : error 0:50 [50]
"websocket is disconnected: Error Domain=NSPOSIXErrorDomain Code=50 \"Network is down\" UserInfo={_kCFStreamErrorCodeKey=50, _kCFStreamErrorDomainKey=1}"

I reconnected the internet, made another mutation from same screen, and it's successful, however, the subscription errors are still being logged at the reconnection interval rate.

I noticed two things while debugging..

  1. Even if I set reconnect = false and try to manually deallocate the subscription by setting to nil or call .cancel and reassign it again, the same errors are getting logged.

  2. I was debugging the library source code, and added few breakpoints here and there, and surprisingly sometimes the subscription was restored. This happened few times but I couldn't infer the exact steps to reproduced.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions