-
Notifications
You must be signed in to change notification settings - Fork 74
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
My connection is established, but I can't invoke functions #89
Comments
Good Day I currently have the same issue has it ever been solved? Error: Object Reference not set to an instance of an object Regards |
Could you share more code? Is it structured similar to the SwiftR demo app? I'm wondering if you have the hub declared such that it's no longer in scope by the time the |
Hi thanks for your reply I have structured it almost 100% like the demo except its all in a class that is created globally as signalR is used throughout the whole application so its done like this so that it runs once when the application has finished loading other values. What works is I can receive the events for on and signal r stays connected throughout the app i can recieve its posts but the second I Invoke I either get "Error: Object Reference not set to an instance of an object" and then have to click the button 2 or 3 times before the invoke actually goes through. Do you know anything that could cause this. The signalR implimentation was setup by my companies previous developers with no documentation so I am unsure of what the issue could be. Like I said if I spam the send button it works now and again Sorry for late reply our time-zones must be different Regards var simpleHub: Hub! var hubConnection: SignalR! init() {
// hubConnection.start() } func StartSignalRConnection(){
} func StopSignalRConnection(){
} func SendMessage(HotelID: CLong!, Message:String!){
} |
Actually, |
Hi Thanks for the reply i will contact my API developer and ask him to confirm what the transport type is. What do you recommend using ? Regards |
Hi. I'm using your library for an iOS app. I have almost the same issue, but I made SignalR to use WebSockets with headers, but just the first time I established the connection with SignalR and I could use invoke to get info from the server without errors. In headers, I send an access token for my server. After that, I restarted the app and it tried to establish a new connection. Then SignalR tried first ServerSentEvents, which didn't work with authorization. Next, it tried LongPolling. The authorization was successful but every time I use Invoke I get the same error message: "Object reference not set to an instance of an object." As you say that SwiftR doesn't support custom headers with WebSockets, how could it work the first time? And after using WebSockets the first time, why is not using it the next time when I restart the app? Could we say that LongPolling doesn't work on iOS? Thank you in advance! |
Any solution so far? My connection to Hub is established and I have connectionId as well. But I'm unable to call any server method and get following error everytime. |
@zahid119 did you find any solution for that. ? |
Yes. I accidentally set all my hub functions private. I updated them to public and it worked perfectly. The connection was always getting established because Connect and Disconnection functions were overridden from parent class. |
My connection is established, but I can't invoke functions. Surprisingly, the function on my hub did not even trigger (found out by logging every method call on my hub).
I have already tried invoking through a web browser and it's working fine, so I doubt the problem's from my SignalR hub. Would you kindly assist me again?
I am currently using signalR v2.2.1 and SwiftR 0.13.0
How I initialise my connection:
let connection = SignalR(serverDomain + "/signalR")
connection.useWKWebView = true
connection.signalRVersion = .v2_2_1
How I setup my hub:

I've also tried invoking with the handle response, but it does not seem to be working or returning any feedback:
try(hub.invoke("testConnection", arguments: nil) { (result, error) in
print('FEEDBACK! :D')
})
The text was updated successfully, but these errors were encountered: