I have the following code in a console app:
var connection = new Connection("http://localhost/xxx/signalr");
connection.Error += ex =>
{
string msg = string.Format("***SignalR Error: {0}", ex.ToString());
Debug.WriteLine(msg);
};
connection.Received += data =>
{
string msg = string.Format("***SignalR Received: {0}", data);
Debug.WriteLine(msg);
};
connection.Start().ContinueWith(task =>
{
if (task.IsFaulted)
{
string msg = string.Format("***SignalR Failed to start: {0}", task.Exception.GetBaseException());
Debug.WriteLine(msg);
}
else
{
string msg = string.Format("***SignalR Started: {0}", connection.ConnectionId);
Debug.WriteLine(msg);
connection.Send("Hello");
}
});
Debugging the server, I can see the OnConnected
and OnReceived
are called.
If I place the same code in a coded WebTest, the OnConnected
on the server is called, but the connection.Send
is not received on the server.
Q: Is it possible to use the SignalR .Net Client in a WebTest?
Q: What is the best way to use a SignalR Persistent Connection in a WebTest?
Thanks