SignalR-Client-Swift
SignalR-Client-Swift copied to clipboard
Does it support watchOS
While trying to add it to my watchOS project, I get the following error.
[!] The platform of the target watch (watchOS 2.0) is not compatible with SignalRSwift (2.0.3), which does not support watchOS.
Do you provide watchOS support?
I have never tried watch OS but I am not aware of any reason why it wouldn't work. The only caveat I know is that WebSockets support was added to later watchOS versions so older versions cannot use it:
https://github.com/moozzyk/SignalR-Client-Swift/blob/3713222eb4dd4c7c3e669595887e39ba35a43693/Sources/SignalRClient/WebsocketsTransport.swift#L11
If you are using CocoaPods then I can see that the spec does not list watchOS
https://github.com/moozzyk/SignalR-Client-Swift/blob/e70c77151872a4f973fe1c10376980b0db3fa4b2/SwiftSignalRClient.podspec#L11-L13
Possibly it should be added there
Hello, I added the library manually. I added the dependencies via pod.
func signalrConnect(access_token: String){
let hubConnection = HubConnectionBuilder(url: URL(string: "URL")!)
.withHttpConnectionOptions() { httpConnectionOptions in
httpConnectionOptions.accessTokenProvider = { return access_token }
}
.build()
hubConnection.delegate = self
hubConnection.start()
}
func connectionDidOpen(hubConnection: HubConnection) {
print(hubConnection.connectionId ?? "")
}
func connectionDidFailToOpen(error: Error) {
}
func connectionDidClose(error: Error?) {
}
I am using it as shown above.
It returns an error like this:
SignalrProjectTest[2714:1337538] Task <03015F69-7125-4808-B11D-7E21FA4AF7C8>.<1> finished with error [-1011] Error Domain=NSURLErrorDomain Code=-1011 "There was a bad response from the server." UserInfo={NSErrorFailingURLStringKey=(url)?id=xIAl5QGELCndqaOYjzacWg, NSErrorFailingURLKey=(url)?id=xIAl5QGELCndqaOYjzacWg, _NSURLErrorWebSocketHandshakeFailureReasonKey=0, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalWebSocketTask <03015F69-7125-4808-B11D-7E21FA4AF7C8>.<1>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalWebSocketTask <03015F69-7125-4808-B11D-7E21FA4AF7C8>.<1>, NSLocalizedDescription=There was a bad response from the server.}
I also tried the same in an ios project. I am getting the same error. My services are running. I am using it in my Flutter project.
I'm having trouble adding an access token. Can you help me?
It is hard to tell what's going on without more details - the error message is quite generic and you need to understand what the server is responding with to understand what needs to be fixed. The first thing to do is to enable logging at the debug level like here:
https://github.com/moozzyk/SignalR-Client-Swift/blob/4e776a9c26300de7612b956954a6fac51eeddb8d/Tests/SignalRClientTests/HubConnectionTests.swift#L101
and check the logs.
The way you set access token looks correct to me but I don't know if you are setting a correct access token.
Your code is not correct with regards to the lifetime of the hub connection instance. It is not a problem yet but once you are able to connect your connection will close immediately. See: https://github.com/moozzyk/SignalR-Client-Swift/wiki/Frequently-Asked-Questions#the-connection-is-being-closed-immediately-after-opening
Tried to enable watchOS today but ran into: https://github.com/CocoaPods/CocoaPods/issues/11558
I added it manually. Currently watchos works without any problems.
Thanks for confirming! I will add watchOS to the podspec once the Cocoapod issue is resolved
On Wed, Oct 26, 2022, 5:41 AM 1garipdeveloper @.***> wrote:
I added it manually. Currently watchos works without any problems.
— Reply to this email directly, view it on GitHub https://github.com/moozzyk/SignalR-Client-Swift/issues/246#issuecomment-1291974589, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAK7JJFDOHJPHMTXMRKB4LDWFERIZANCNFSM544V6QXA . You are receiving this because you commented.Message ID: @.***>