-
Notifications
You must be signed in to change notification settings - Fork 147
Description
PROBLEM: Actual error message returned by server is not passed on to the delegate connectionDidClose() method
If I pass wrong authentication code (which I received in login API) to the server then server dont create connection (wihch is our business requirement) and returns a error message which I can see in logs printed by library (Message received: {“type”:7,“error”:“Connection closed with an error. HubException: Provided auth-code is failed to authorize.“}) as mentioned below in logs, subsequently connectionDidStop() method is called but I recieve error = nil or sometime improper message like not found 404 etc. But not the actual reason which is printed by createHubMessage(payload: Data) in JSONHubProtocol class
Expected behavior
connectionDidClose() should return the reason that is printed in debug logs i.e "Connection closed with an error. HubException: Provided auth-code is failed to authorize."
Logs
2020-09-30T10:22:36.841Z debug: Data received
2020-09-30T10:22:36.841Z debug: Processing handshake response: {}
======connectionDidOpen(hubConnection:)======
2020-09-30T10:22:36.842Z debug: Payload contains 0 message(s)
2020-09-30T10:22:36.845Z debug: Received data from transport
2020-09-30T10:22:36.845Z debug: Data received
2020-09-30T10:22:36.846Z debug: Payload contains 1 message(s)
2020-09-30T10:22:36.846Z debug: Message received: {“type”:7,“error”:“Connection closed with an error. HubException: Provided auth-code is failed to authorize.“}
2020-09-30T10:22:36.848Z info: WebSocket close. Clean: true, code: 1000, reason:
2020-09-30T10:22:36.848Z info: Transport closed
2020-09-30T10:22:36.848Z debug: Attempting to chage state from: ‘(nil)’ to: ‘stopped’
2020-09-30T10:22:36.848Z debug: Changing state to: ‘stopped’ succeeded
SwiftSignalRClient was compiled with optimization - stepping may behave oddly; variables may not be available.
2020-09-30T10:22:36.848Z debug: Previous state connected
2020-09-30T10:22:39.618Z debug: Invoking connectionDidClose (transportDidClose(_:): 260)
2020-09-30T10:22:49.549Z info: Stopping connection
2020-09-30T10:22:49.549Z debug: Attempting to chage state from: ‘(nil)’ to: ‘stopped’
2020-09-30T10:22:49.549Z debug: Changing state to: ‘stopped’ succeeded
2020-09-30T10:22:49.549Z info: Connection already stopped
2020-09-30T10:22:49.550Z info: HubConnection closing with error: nil
2020-09-30T10:22:49.551Z info: Terminating 0 pending hub methods
======connectionDidClose(error:) error=nil ======
Code To Reproduce the Issue
- Running the app which creates connection with the provided SignalR URL
- Passing invalid auth-code in header.
Additional context
As per our requirement server should not establish a connection if provided auth-code in header in HubConnectionBuilder.withHttpConnectionOptions is invalid.
Any help would by highly appreciatable! Thanks in advance