adamhartford / SwiftR

Swift client for SignalR (iOS and Mac)
MIT License
174 stars 74 forks source link

Error In Connecting to my server #50

Open vahidamini opened 8 years ago

vahidamini commented 8 years ago

Hello

I have these parameters to connect my SignalR server Server Address : http://myurl.com Hub Proxy : TaxiTopHub Query String: "user_type=client"

I configured my connection like this

hubConnection = SwiftR.connect("http://myurl.com") { [weak self] connection in connection.queryString = ["user_type": "client"] self?.simpleHub = connection.createHubProxy("TaxiTopHub")

but when I run my code I get this error : SwiftR unable to process message 1i9k4s3y: Error Domain=WKErrorDomain Code=5 "JavaScript execution returned a result of an unsupported type" UserInfo={NSLocalizedDescription=JavaScript execution returned a result of an unsupported type}

Please help me if it's possible

adamhartford commented 8 years ago

What version of SignalR are you using? And what version of SwiftR? And does this error happen after connecting, or after you try to invoke some server method?

vahidamini commented 8 years ago

My signalR version is 2.0 and swiftR version is the latest that published. This error happen while connecting. thanks for your response.

adamhartford commented 8 years ago

Did you set the SignalR version to 2.0?

SwiftR.signalRVersion = .v2_0_0
vahidamini commented 8 years ago

Yes I set it up with the same code you mentioned. But unfortunately I get this error again:

SwiftR unable to process message oxd6kero: Error Domain=WKErrorDomain Code=5 "JavaScript execution returned a result of an unsupported type" UserInfo={NSLocalizedDescription=JavaScript execution returned a result of an unsupported type}

vahidamini commented 8 years ago

I was upgraded my SignalR to 2.1.0 It works, but now any time I run my code the hubconnectio.state is Disconnected why?

     SwiftR.transport = .ServerSentEvents
    SwiftR.signalRVersion = .v2_1_0 
    hubConnection = SwiftR.connect("http://myurl.ir") { [weak self] connection in
        connection.queryString  = ["user_type": "client"]
        self?.simpleHub = connection.createHubProxy("TaxiTopHub")
       print(self!.hubConnection.state)
}
vahidamini commented 8 years ago

Finally I solve it.

adamhartford commented 8 years ago

What was the issue?

mowali commented 8 years ago

vahidamini could you please take the time to answer Adam's question? You may need him again!!

vahidamini commented 8 years ago

I was wrong , uncommenting this line of my code solved my problem: SwiftR.useWKWebView = true Thanks Adam.

mowali commented 8 years ago

thanks for the answer. it didn't solve it for me. still get: SwiftR unable to process message 3k7umb08: Error Domain=WKErrorDomain Code=5 "JavaScript execution returned a result of an unsupported type" UserInfo={NSLocalizedDescription=JavaScript execution returned a result of an unsupported type}