New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to return after waiting for 10 seconds. #26
Comments
You should only get that error message when debugging. The WebView stops executing JavaScript calls after 10 seconds. You will only hit that when you set a breakpoint somewhere in code that's part of a JavaScript callback. It's on my todo list to look at that, but it's been a very low priority since it's really been a non-issue so far. As far as your code above, I see a few issues. I would suggest you try to get the demo app working with your server and go from there. The code should look more like this: SwiftR.connect("http://maisad-001-site1.btempurl.com/signalr/") { connection in
let simpleHub = connection.createHubProxy("maisAdChatHub")
// Event handler
simpleHub.on("newMessage") { args in
print("Send Messageeeeeeeee")
print("Response : \(args)")
}
connection.connected = {
// Invoke server method and handle response
simpleHub.invoke("sendmessage", arguments: ["Simple Test", "Room1" , "Usernamee" , "photo"]) { (result, error) in
if let e = error {
print("Error message: \(e)")
} else {
print("Success!")
if let r = result {
print("Result: \(r)")
}
}
}
}
} You don't need to call Lastly, it looks like you want to invoke a SignalR server method as soon as the client is connected, so I've tried to update your code accordingly. There's a callback for when the client has actually connected. If you look at the code I've proposed above, you'll see that it:
This series of steps results in the newMessage callback handler being invoked as soon as possible after the view is loaded. I've run this code against my own test server to verify that it works. From here, you'll just have to make sure your server methods are defined correctly, you're using the right names, etc. |
I was looking for your @adamhartford comments and I got what I was looking for... Let me try ... 👍 |
@adamhartford I tried running the SwiftR iOS Demo project. but I got this message in console
|
That means there's something wrong with your server. (Did you make sure the URL is correct?) What happens when you browse to http://maisad-001-site1.btempurl.com/signalr/hubs in a browser both on your desktop and on your phone? |
I get the javascript code while browsing to http://maisad-001-site1.btempurl.com/signalr/hubs |
OK, well that's a good sign. I think you should try to write a simple test page that uses the SignalR JavaScript client to test your server. If that works, there's no reason your iOS app shouldn't work as well. You could also try running Charles Proxy to inspect the traffic to your server. I've run the same code against my server and it works, so I'd probably need to see more of your iOS/.NET code to help you. |
well .....I have tried the same code I got from your Github page in your server , and tried the code you made above... |
Have you tried Charles Proxy? Watch the traffic to the server, see what's happening? Also, what version of SignalR are you using? |
This server is working fine for a developer who is creating a hybrid application. I don't know why it's not working for me.... and when I used Charles proxy it showed a 400 error... 👎 |
A 400 is expected when browsing to /signalr. You should get a 200 with /signalr/hubs. Do you have CORS enabled on your server? // Server
app.UseCors (CorsOptions.AllowAll); When you browse to /signalr/hubs, what version of the JavaScript library does it return? |
I am currently using SignalR version v2.2.0 and javascript library version returned is v2.1.1 and of-course I have enabled CORS in my server... |
Are you positive about CORS? I notice both URLs you've posted here are publicly available, so I tried both with WKWebView and get:
That indicates CORS is not enabled. If I use UIWebView, the server returns an error (500). Correction: your btempurl.com returns a 500 with UIWebView. The cynere.net connects OK. |
Now I see: "You are using a version of the client that isn't compatible with the server. Client version 1.5, server version 1.4." I don't know how you're using SignalR 2.2.0, but get 2.1.1 JavaScript. You should see 2.2.0 in the JavaScript as well. If using NuGet, can you double check your packages? And maybe make sure you haven't deployed multiple versions of SignalR? |
Sorry @adamhartford .... I am using signalr ver 2.1.1. it's my mistake I checked it in the nuget online packages rather than in the installed packages... I tried a lot with SWIFTR but it didn't even work. being new with iOS development I am not able get how your library works and what I need add to my code. I will try again. I will let you know my result's.... 👍 |
Hi.. @adamhartford Now I got a 200 status as response in by using charles. I took the Url from Charles and got this in browser but in the demo project the code rans to the error section as I have shown in the above question. |
Looks like you're still using SignalR 2.1.1 instead of 2.2.0. Then, if you're still using the demo project, make sure you replace Also, I have a development version of SwiftR where you can now specify the server version you're using: SwiftR.signalRVersion = .v2_1_1 I might change this API depending on what versions I can support, but I can confirm that with my suggested changes above (and using 2.1.1), everything works. Fo now, you'll need to make those changes, and be sure to run SignalR version 2.2.0. |
one of our developer is working with a hybrid app and he uses signalr too. I used his server to test whether my code works , I have changed signalr version to 2.2.0 and did whatever I needed to but still no change . |
@adamhartford Thank you for the replies you made all the time. Now everything is working fine... 👍 |
I have been trying SwiftR for a week. but when I ran the project I got nothing. In viewDidLoadMethod I have set this code
I put a breakpoint at line number 7 where simpleHub.on("newMessage") is called am getting a message in console and it is
2016-02-02 15:04:33.131 CHATAPP[3089:374824] void SendDelegateMessage(NSInvocation *): delegate (webView:decidePolicyForNavigationAction:request:frame:decisionListener:) failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode
No Idea whats's going wrong... Need help!!!
The text was updated successfully, but these errors were encountered: