determine client reconnect to server - signalr

I use client disconnect event on the server to determine when the client disconnected from the server. But I need to know when the client has reconnected. Can I do this? I am running SignalR in a WebView on a mobile device and I assume loss of signal causes SignalR disconnect to fire on the server

Try having your Hub implement the IConnected interface, more info here.
This gives you these methods:
Task Disconnect()
Task Connect()
Task Reconnect(IEnumerable<string> groups)

Related

SignalR status of the connection

Makes messaging on SignalR. Client - .NET 4.5 local application.
I do not know how to check the status of the connection with the client on the server side. The fact is that when connecting the user logs in the server. And if you disable a user account is deleted from the server.
If the client application is not completed normally, for example as a result of exceptions, On Disconnected method on the server is not called, and the user account is not deleted.
Tell me how you can solve the problem, if anyone knows.
I read somewhere that SignalR is smart enough to handle disconnection and remove the disconnected client from the group automatically, so no need to worry about the anormal disconnect events.

signalr scaleout sending message to only particular client

As I went through the documentaion of signalr scaleout options having a backpane, i see the backpane job is to send the message from one server to all signalr servers. If so, if Server 1 wants to send message to particular client, the message goes to backpane and from there to all other servers(ex. server 2,3)..where the client 1 is connected with Server 1. So can we restrict this to send only from server1 to client 1. Also the other question, are the events like connected, reconnected also will be routed to backpane and to all other servers ?
thanks
If you are using a SignalR backplane, all messages will be sent to all servers. There is no way to configure a SignalR scaleout provider to only send messages to specific servers. It's all or nothing.
If you choose to forgo a backplane, you could of course configure SignalR to use its default in-memory message store and then manually send inter-server messages.
Events like connected/reconnected/disconnected do not involve publishing messages so no messages will be routed to all other servers.

SignalR block a connection from the server (Taks cancel)

In the SignalR (server) hub I want do a license check. If the check negativ then I want in the OnConnected of the Hub block the connection. The client should get in the Hub start the Task as canceled with a message (no valid licence).
When I return a Task with a Aggregate Exception in the OnConnected of the SignalR Hub then the client gets a fault state, with a timeout exception.
How can I block the connection to the SignalR hub and give the client a message why I have block the connection?
As far as I know you can't just start or stop connections already on the server. The client has to disconnect itself. If you want to use the hub for licence check you need to have the client connect - send licence info - server checks and if it is invalid call $client.disconnect on the client.
The other option like blorkfish mentions is to allow them to connect, add them to a list and check this when they call methods on the server.
I don't think that you should block the connection with an Exception. Your client would then not be able to tell if there was a genuine error in the SignalR connection.
Rather send a specific SignalR message back that there is no license - and then manage the connection object on the server side.
Keep a list of licensed connections, and a list of unlicensed connections.
So instead of using Clients.All to broadcast, use Clients.Client("< client_connection_id >") to broadcast.
Hope this helps.

How to initialize and connect to LDAP Server without using ldap_open()

How to initialize and connect to OpenLDAP Server without using ldap_open() function.
I would like to test the feature LDAP test connection for this I need to open a connection with timeout and close it to check if the connection is available or not.
Just create a socket and call connect(), using non-blocking mode and your choice of select()/poll()/epoll() to control the timeout. Close it immediately on success, don't send anything.

SignalR not invoking result with DNS alias on client

I connect to my server, which is load balanced for an alias to point to 2 servers, 01 & 02 and it round-robins connections for arguments sake. I can connect to the hub without a problem, and I can even send stuff to the server, but when it goes to return it to the client, I never get my methods invoked. If I bypass the load balancer and use the server name explicitly, it always works just fine.
I'm even tracing it, and I send back the message from the exact originating server with the Clients.Client(clientId).completeJob(stuff), and that executes fine on the server, but if I ContinueWith, it never gets finished.
Oh, and it's connected with server sent events. Am I missing something or is this just not supported?
Server-sent events establishes a long running connection, but unlike WebSockets, it isn't bidirectional. The connection can only be used to push data to the client.
SignalR uses regular XHRs to send data from clients when the WebSocket transport is unavailable. This means that the load balancer will likely route client-to-server hub method invocations to a server different than the one the client originally established a server-sent event connection with.
The server executing Clients.Client(clientId).completeJob(stuff) likely doesn't own the connection that would allow it to push a message to the specified client. (Though returning a value from a hub method on the server will send data back to the client via the same connection that invoked the method.)
SignalR can work behind a load balancer. It just requires a little more setup so all the SignalR servers can communicate with each other via a backplane such as Service Bus or Redis. This allows messages to get dispatched to the server that owns the server-to-client connection.
https://github.com/SignalR/SignalR/wiki/Azure-service-bus details how you can setup a Service Bus backplane on Azure.

Resources