aspnet / SignalR-samples

Samples for ASP.NET Core SignalR
753 stars 400 forks source link

There were no compatible transports on the server. #61

Open Ktirumalsetty opened 5 years ago

Ktirumalsetty commented 5 years ago

How to fix the below error from hubConnection.start().blockingAwait();

Caused by: java.lang.RuntimeException: There were no compatible transports on the server. at com.microsoft.signalr.HubConnection.lambda$startNegotiate$11(HubConnection.java:364) at com.microsoft.signalr.-$$Lambda$HubConnection$GiLlPVdlbvryuPaYB9UmGffcsYc.apply(Unknown Source:8) at io.reactivex.internal.operators.single.SingleFlatMap$SingleFlatMapCallback.onSuccess(SingleFlatMap.java:76) at io.reactivex.internal.operators.single.SingleMap$MapSingleObserver.onSuccess(SingleMap.java:64) at io.reactivex.subjects.SingleSubject.onSuccess(SingleSubject.java:141) at com.microsoft.signalr.DefaultHttpClient$2.onResponse(DefaultHttpClient.java:124) at okhttp3.RealCall$AsyncCall.execute(RealCall.java:153)

mikaelm12 commented 5 years ago

Hi @Ktirumalsetty. The error message There were no compatible transports on the server. Means that there there was no overlap between the transports on the server and the transports on the client. The Java client only has support for websockets now so that means that your server doesn't support websockets. Are you using app service to host your server? Websockets are generally not enabled by default so I'd recommend going into your app settings on the dasshboard of what ever cloud provider you're using and make sure that Websockets are enabled. If they are enabled and you're still getting this issue. I'll follow up futher. Thanks!

bradygaster commented 5 years ago

Just in case, here's a picture of where to enable it in the Azure portal for an App Service.

websocket
josemauricio2 commented 5 years ago

I'm having the same issue but my in my case its a windows advanced server 2016 behind a load balancer. I've installed WebSockets on the server; could it be the load balancer, do I need to open any port number?

mohamed-gearbox commented 4 years ago

Hi @mikaelm12 , we're using com.microsoft.signalr:signalr:1.0.0 and getting same error

There were no compatible transports on the server

when attempting to connect to SignalR app on azure app service. WebSockets is enabled on app service configuration but still getting same error.

When digging deeper we realized that there was nothing returned in the availableTransports in response on HubConnection startNegotiate.

mikaelm12 commented 4 years ago

I'd first recommend using a newer version of the package. There have been several updates with various fixes released since 1.0.0

mohamed-gearbox commented 4 years ago

Thank you @mikaelm12 but the version we're using seems to be the latest per Microsoft documentation:

https://docs.microsoft.com/en-us/aspnet/core/signalr/java-client?view=aspnetcore-3.1

Can you please point me to where to get newest release?

I want to also note that when we hosted the signalr app on a VM server on Azure, android client 1.0.0 connected fine and received list of available transports, and send/receive of messages was smooth.

The current problem we're facing is when the signalr app is hosted on Azure App Service with WebSockets enabled and android client is trying to connect to it. We also use a javascript signalr web client that connects fine to the Azure App Service signalr web app where connect/start uses transport=webSockets correctly...

mikaelm12 commented 4 years ago

https://search.maven.org/artifact/com.microsoft.signalr/signalr Here are all the released versions of the Asp.Net Core SignalR Java client

mohamed-gearbox commented 4 years ago

Thanks @mikaelm12 , I should have mentioned this earlier, my apologies! but we've inherited a legacy VB.net application targeting .NET 4.5 framework and using Microsoft.AspNet.SignalR.Core v2.2.2 which is hosted on Azure App Services. When I tried 3.X package on Android it complained about server not being Signalr Core.

And so we still can't get Android to connect to the .../signalr endpoint as it throws "There were no compatible transports on the server." using 1.X package, since nothing is returned in availableTransports, and check fails to find "WebSockets"

When I hit .../signalr/negotiate endpoint over a browser, i get the following:

{"Url":"/signalr","ConnectionToken":"ZEMaFAfM134A224t0gNwknjdd79iqN6HzGfjSQ3sM7HoGMo7XV6bnOR+iiPwLOGffvouAe00/hih0ApU7FZNXtw0uU0q9/FqQnGif84r5Z+ClUjWr1qHfezrktfYjgRa","ConnectionId":"872bf5b3-1af9-474f-adc5-8d097f310059","KeepAliveTimeout":40.0,"DisconnectTimeout":60.0,"ConnectionTimeout":150.0,"TryWebSockets":true,"ProtocolVersion":"1.2","TransportConnectTimeout":5.0,"LongPollDelay":0.0}

This is the Startup configuration in application Startup.vb

Public Sub Configuration(app As IAppBuilder)

        app.Map("/signalr", Sub(map)
                                map.UseCors(CorsOptions.AllowAll)

                                Dim Config = New HubConfiguration
                                Config.EnableDetailedErrors = True
                                Config.EnableJSONP = True

                                map.RunSignalR(Config)
                            End Sub)

    End Sub

Are we using the wrong Android signalr client altogether!? Is there an Android client that we can use to connect successfully?

mikaelm12 commented 4 years ago

Okay yes, there is your problem. Core and Classic client and servers are not compatible. There is an older SignalR Java client but it's not supported and hasn't been updated in a few years. I'm not endorsing that you use it, but here it is if you're interested in checking it out https://github.com/SignalR/java-client It's marked as obsolete

pinkesh79 commented 2 years ago

Hi @Ktirumalsetty. The error message There were no compatible transports on the server. Means that there there was no overlap between the transports on the server and the transports on the client. The Java client only has support for websockets now so that means that your server doesn't support websockets. Are you using app service to host your server? Websockets are generally not enabled by default so I'd recommend going into your app settings on the dasshboard of what ever cloud provider you're using and make sure that Websockets are enabled. If they are enabled and you're still getting this issue. I'll follow up futher. Thanks!

Hi @Ktirumalsetty - This has resolved my issue by Enabling the Websocket option in Azure. Thanks a ton!