Skip to content
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

"There was an error invoking Hub" Swift 4 #109

Open
munsifhayat opened this issue Mar 1, 2018 · 5 comments
Open

"There was an error invoking Hub" Swift 4 #109

munsifhayat opened this issue Mar 1, 2018 · 5 comments

Comments

@munsifhayat
Copy link

Hi everyone !
I am really stuck into this issue. I am passing these arguments:

let message = ["feedbackId": 79, "chatText": "Complex Test", "toId": "4b556216-20ca-4338-b055-6f8dbbaee5ff",
"fromId":userGuidID] as [String : Any]

            print(message)
            
            do {
                if let invokingHub = simpleHub {
                    
                    try invokingHub.invoke("SendInstantMessage", arguments: [message]) { (result, error) in

                        if let e = error {
                        
                            print("Error: \(e)")
                        
                        } else {
                            print("Success!")
                            if let r = result {
                                print("Result: \(r)")
                                
                                DispatchQueue.main.async {
                                    let message =  self.chatWindow?.sendText(text, isIncomingMessage: false)
                                    self.chatWindow?.addMessageToMessenger(message!)
                                }
                            }
                        }
                    }
                }
                
            } catch {
                //handle error
                print(error)
            }

My Arguments Output : This I am sending to server. Which is same as my Android fellow. I am receiving messages but not able to send.

{"chatText":"Complex Test","toId":"4b556216-20ca-4338-b055-6f8dbbaee5ff","feedbackId":80,"fromId":"67aaffb6-e403-4fcc-a208-fdec55bcc1f4"}

@munsifhayat munsifhayat changed the title "There was an error invoking Hub" "There was an error invoking Hub" Swift 4 Mar 1, 2018
@SentoCrespo
Copy link

Any news? I can only receive messages but cannot invoke anything on the server. Even the callback does NOT get called...

Ivce tried with a simpler message, only invoke a method, no parameters.

Using Swift 4, Xcode 9.2, Pods

Any help or workaround in here?

@SentoCrespo
Copy link

More information:
useWKWebview is not set to true (so it's false).

This is quite annoying and frustrating.

Any advise guys? Thanks.

@adamhartford
Copy link
Owner

Would someone be able to share an example project that demonstrates the issue, or show how it can happen using the Demo application?

@SentoCrespo
Copy link

I'm afraid I can't do that. If I set the option
useWKWebview = true

Then the connection fails, so I guess the server doesn't have Cors enabled as the readme states.

SignalR version is 2.2.2 though.

@munsifhayat
Copy link
Author

Its working great on my side now.
Here are my findings :
-> Enable CORS at your backend side.
-> Look into your modal that you are passing.
if not solved than look again to your modal.

Here is my modal and the way it worked for me.

    let m = "{\"chatText\":\"\(chatText)\",\"todIdList\":\(toSendIds),\"feedbackId\":\(feedbackId),\"messageTextType\":1001,\"fromId\":\"\(userGuid)\"}"
    
    do {
        if let invokingHub = simpleHubVendor {
            
            try invokingHub.invoke("SendInstantMessage", arguments: [m]) { (result, error) in
                
                if let e = error {
                    print("Error: \(e)")
                } else {
                    print("Success!")
                    if let r = result {
                        print("Result: \(r)")
                        
                    }
                }
            }
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants