florianmari / LiveGQL

Use GraphQL Subscriptions on iOS :ok_hand:
MIT License
83 stars 11 forks source link

Crash on reconnect #9

Open psi-gh opened 6 years ago

psi-gh commented 6 years ago

I have such crash. It occurring in ~1 minute after running app if I specify reconnect: true in gql.initServer(connectionParams: nil, reconnect: true) If I set reconnect to false, there won't be crash, but subscription will stop in 1 minute without any notice.

*** Assertion failure in -[SRWebSocket open], /Pods/SocketRocket/SocketRocket/SRWebSocket.m:389
 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Cannot call -(void)open on SRWebSocket more than once'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010444c12b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x0000000100e17f41 objc_exception_throw + 48
    2   CoreFoundation                      0x00000001044512f2 +[NSException raise:format:arguments:] + 98
    3   Foundation                          0x00000001008b8d69 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
    4   SocketRocket                        0x00000001007ca323 -[SRWebSocket open] + 355
    5   LiveGQL                             0x000000010079d8e0 _T07LiveGQLAAC9webSocketySQySo05SRWebD0CG_Si16didCloseWithCodeSQySSG6reasonSb8wasCleantF + 192
    6   LiveGQL                             0x000000010079d9fd _T07LiveGQLAAC9webSocketySQySo05SRWebD0CG_Si16didCloseWithCodeSQySSG6reasonSb8wasCleantFTo + 253
    7   SocketRocket                        0x00000001007d3fcb __34-[SRWebSocket stream:handleEvent:]_block_invoke_3 + 187
    8   libdispatch.dylib                   0x0000000105c2c2f7 _dispatch_call_block_and_release + 12
    9   libdispatch.dylib                   0x0000000105c2d33d _dispatch_client_callout + 8
    10  libdispatch.dylib                   0x0000000105c385f9 _dispatch_main_queue_callback_4CF + 628
    11  CoreFoundation                      0x000000010440ee39 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    12  CoreFoundation                      0x00000001043d3462 __CFRunLoopRun + 2402
    13  CoreFoundation                      0x00000001043d2889 CFRunLoopRunSpecific + 409
    14  GraphicsServices                    0x0000000109a779c6 GSEventRunModal + 62
    15  UIKit                               0x00000001016b45d6 UIApplicationMain + 159
    16  xxxxxxxx                            0x00000001003842c7 main + 55
    17  libdyld.dylib                       0x0000000105ca9d81 start + 1
    18  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException`
florianmari commented 6 years ago

Hey!

Thank you for reporting this, I'm gonna check and add some unit tests for the future!

aparandiy commented 6 years ago

Hi, have the same issue - app crashes after few minutes, reason - 'Cannot call -(void)open on SRWebSocket more than once'

psi-gh commented 6 years ago

@aparandiy Seems like this repo not supporting. You can look at Apollo project.

aparandiy commented 6 years ago

if I am listening for subscriptions from one controller - all works perfect, but if i connect subscriptions more than one controller - it works, but after few minutes of using the app crashes with reason - Cannot call -(void)open on SRWebSocket more than once

florianmari commented 6 years ago

Ok I see where is the bug, I need to rush and push two solutions: