Reputation: 774
I have found SDK of Signalr for Android: https://github.com/SignalR/java-client. My code is working fine when web app is hosted on IIS but when I deploy on Azure, it's not able to connect; it waits forever
While my javascript client code is working fine. I follow following to deploy my web app: http://www.asp.net/signalr/overview/deployment/using-signalr-with-azure-web-sites
Following log I received
AutomaticTransport - Response received<br/>
AutomaticTransport - Read response data to the end<br/>
AutomaticTransport - Trigger onSuccess with negotiation data: {"Url":"/signalr","ConnectionToken":"4GGnSKxMOsuP6jkG1det5Z3Ch073H6ixe3Ium6k69k/RAM/x2KJkHP03XkNnPx56EatX8qxDmSOASS7HGKm5UJtsTqCP71YVJ05vLYrAT4pLYzecAwxziEUotCyVUpOc","ConnectionId":"28e1bb42-f03d-42b9-a874-171be7531eef","KeepAliveTimeout":20.0,"DisconnectTimeout":30.0,"ConnectionTimeout":110.0,"TryWebSockets":true,"ProtocolVersion":"1.3","TransportConnectTimeout":5.0,"LongPollDelay":0.0}<br/>
HubConnection - Negotiation completed<br/>
HubConnection - ConnectionId: 28e1bb42-f03d-42b9-a874-171be7531eef<br/>
HubConnection - ConnectionToken: 4GGnSKxMOsuP6jkG1det5Z3Ch073H6ixe3Ium6k69k/RAM/x2KJkHP03XkNnPx56EatX8qxDmSOASS7HGKm5UJtsTqCP71YVJ05vLYrAT4pLYzecAwxziEUotCyVUpOc<br/>
HubConnection - Keep alive timeout: 20.0<br/>
HubConnection - Entered startLock in startTransport<br/>
HubConnection - Starting the transport<br/>
HubConnection - Starting transport for InitialConnection<br/>
HubConnection - Getting connection data: [{"name":"myhub"}]<br/>
HubConnection - Getting connection data: [{"name":"myhub"}]<br/>
Upvotes: 0
Views: 887
Reputation: 24138
Based on @BNK's comments & my understanding, I post the answer for people have the same issue.
I reviewed the code Connection.java
(https://github.com/SignalR/java-client/blob/master/signalr-client-sdk/src/main/java/microsoft/aspnet/signalr/client/Connection.java) that has two functions called start
. The code of function start
with no argument below use the AutomaticTransport
as the default ClientTransport
.
public SignalRFuture<Void> start() {
return start(new AutomaticTransport(mLogger));
}
And I continued to review the code AutomaticTransport.java
(https://github.com/SignalR/java-client/blob/master/signalr-client-sdk/src/main/java/microsoft/aspnet/signalr/client/transport/AutomaticTransport.java). It try to select the one of the three ClientTransport
in the function initialize
that contains WebSocketTransport
, ServerSentEventsTransport
& LongPollingTransport
, please see below.
private void initialize(Logger logger) {
mTransports = new ArrayList<ClientTransport>();
mTransports.add(new WebsocketTransport(logger));
mTransports.add(new ServerSentEventsTransport(logger));
mTransports.add(new LongPollingTransport(logger));
}
The reason of the issue might be the server using SignalR on Azure that not implement for supporting the three transport of AutomaticaTransport
.
So using the function public SignalRFuture<Void> start(final ClientTransport transport)
of Class Connection
to select a transport suppored by the server-side manually to solve the issue.
Upvotes: 2
Reputation: 24636
SignalR depends on WebSockets. To use SignalR on Azure Web Apps you have to enable WebSockets for your site.
To enable WebSockets go to your site in https://manage.windowsazure.com->Configure->WebSockets->Set to "On"
Upvotes: -1