{"action":"created","issue":{"url":"https://api.github.com/repos/Azure/azure-signalr/issues/115","repository_url":"https://api.github.com/repos/Azure/azure-signalr","labels_url":"https://api.github.com/repos/Azure/azure-signalr/issues/115/labels{/name}","comments_url":"https://api.github.com/repos/Azure/azure-signalr/issues/115/comments","events_url":"https://api.github.com/repos/Azure/azure-signalr/issues/115/events","html_url":"https://github.com/Azure/azure-signalr/issues/115","id":327783409,"node_id":"MDU6SXNzdWUzMjc3ODM0MDk=","number":115,"title":"OnConnectedAsync missing some of the connections","user":{"login":"yigitgursoy","id":5436571,"node_id":"MDQ6VXNlcjU0MzY1NzE=","avatar_url":"https://avatars2.githubusercontent.com/u/5436571?v=4","gravatar_id":"","url":"https://api.github.com/users/yigitgursoy","html_url":"https://github.com/yigitgursoy","followers_url":"https://api.github.com/users/yigitgursoy/followers","following_url":"https://api.github.com/users/yigitgursoy/following{/other_user}","gists_url":"https://api.github.com/users/yigitgursoy/gists{/gist_id}","starred_url":"https://api.github.com/users/yigitgursoy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yigitgursoy/subscriptions","organizations_url":"https://api.github.com/users/yigitgursoy/orgs","repos_url":"https://api.github.com/users/yigitgursoy/repos","events_url":"https://api.github.com/users/yigitgursoy/events{/privacy}","received_events_url":"https://api.github.com/users/yigitgursoy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-30T15:28:12Z","updated_at":"2018-06-02T01:27:10Z","closed_at":null,"author_association":"NONE","body":"I'm creating 10 clients in a loop. Almost all the time, a few of these clients don't trigger the OnConnectedAsync method when they connect to the hub. These clients don't throw any exceptions when they start a connection using the connection.StartAsync() or when the connection.On handler is registered. Which makes it hard to diagnose any problems.\r\n\r\nFiddler traffic displays 10 client/negotiate, 10 client/?hub, 10 /message/negotiate requests. But I see 9 OnConnectedAsync calls in the console.\r\n\r\nThis is the fiddler traffic:\r\n\r\n![image](https://user-images.githubusercontent.com/5436571/40728857-f745c50a-6422-11e8-8d9f-fb3b1a7b80eb.png)\r\n\r\nThis is the Hub's OnConnectedAsync method:\r\n\r\n```csharp\r\npublic override async Task OnConnectedAsync()\r\n{\r\n\tConsole.WriteLine(\"@@@ OnConnectedAsync is executed\");\r\n\tif (Context?.User?.Identity != null)\r\n\t{\r\n\t\tvar playerId = ((System.Security.Claims.ClaimsIdentity)Context.User.Identity).Claims\r\n\t\t\t.First(p => p.Type == \"PlayerId\")\r\n\t\t\t.Value;\r\n\r\n\t\t//some logic\r\n\t}\r\n\r\n\tawait base.OnConnectedAsync().ConfigureAwait(false);\r\n}\r\n```\r\n\r\nThis is the client code:\r\n\r\n```csharp\r\nfor (var i = 1; i <= 10; i++)\r\n{\r\n\t\tvar token = await program.GetToken(i);\r\n\t\tawait program.CreateClient(i, token);\r\n}\r\n\r\nprivate async Task CreateClient(int playerId, string token)\r\n{\r\n\tvar connection = new HubConnectionBuilder()\r\n\t\t.WithUrl(_configurationRoot[\"SignalRHubUrl\"],\r\n\t\t\toptions => options.Headers = new Dictionary<string, string>\r\n\t\t\t{\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t\"Authorization\", $\"bearer {token}\"\r\n\t\t\t\t\t}\r\n\t\t\t})\r\n\t\t.Build();\r\n\r\n\tawait connection.StartAsync();\r\n\r\n\tconnection.On<string>(\"send\", async (m) =>\r\n\t{\r\n\t\tConsole.WriteLine($\"Message received: {m}\");\r\n\t\tawait connection.StopAsync();\r\n\t});\r\n\r\n\tConsole.WriteLine($\"Player {playerId} connected.\");\r\n}\r\n```\r\n\r\nThese are the console logs that display OnConnectedAsync's:\r\n\r\n`\r\nNow listening on: http://localhost:51234\r\nApplication started. Press Ctrl+C to shut down.\r\ninfo: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[3]\r\n      HttpConnection Started.\r\ninfo: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[3]\r\n      HttpConnection Started.\r\ninfo: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[3]\r\n      HttpConnection Started.\r\ninfo: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[3]\r\n      HttpConnection Started.\r\ninfo: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[3]\r\n      HttpConnection Started.\r\ninfo: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]\r\n      Request starting HTTP/1.1 POST http://localhost:51234/message/negotiate  0\r\ninfo: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler[2]\r\n      Successfully validated the token.\r\ninfo: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[1]\r\n      Authorization was successful.\r\ninfo: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]\r\n      Request finished in 264.7313ms 200 application/json\r\ninfo: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]\r\n      Request starting HTTP/1.1 POST http://localhost:51234/message/negotiate  0\r\ninfo: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler[2]\r\n      Successfully validated the token.\r\ninfo: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[1]\r\n      Authorization was successful.\r\ninfo: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]\r\n      Request finished in 8.4074ms 200 application/json\r\ninfo: Microsoft.AspNetCore.SignalR.HubConnectionContext[1]\r\n      Completed connection handshake. Using HubProtocol 'json'.\r\ninfo: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]\r\n      Request starting HTTP/1.1 POST http://localhost:51234/message/negotiate  0\r\ninfo: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler[2]\r\n      Successfully validated the token.\r\ninfo: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[1]\r\n      Authorization was successful.\r\ninfo@@@ OnConnectedAsync is executed\r\n: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]\r\n      Request finished in 7.6316ms 200 application/json\r\ninfo: Microsoft.AspNetCore.SignalR.HubConnectionContext[1]\r\n      Completed connection handshake. Using HubProtocol 'json'.\r\n@@@ OnConnectedAsync is executed\r\ninfo: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]\r\n      Request starting HTTP/1.1 POST http://localhost:51234/message/negotiate  0\r\ninfo: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler[2]\r\n      Successfully validated the token.\r\ninfo: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[1]\r\n      Authorization was successful.\r\ninfo: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]\r\n      Request finished in 13.7569ms 200 application/json\r\ninfo: Microsoft.AspNetCore.SignalR.HubConnectionContext[1]\r\n      Completed connection handshake. Using HubProtocol 'json'.\r\n@@@ OnConnectedAsync is executed\r\ninfo: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]\r\n      Request starting HTTP/1.1 POST http://localhost:51234/message/negotiate  0\r\ninfo: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler[2]\r\n      Successfully validated the token.\r\ninfo: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[1]\r\n      Authorization was successful.\r\ninfo: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]\r\n      Request finished in 8.4681ms 200 application/json\r\ninfo: Microsoft.AspNetCore.SignalR.HubConnectionContext[1]\r\n      Completed connection handshake. Using HubProtocol 'json'.\r\n@@@ OnConnectedAsync is executed\r\ninfo: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]\r\n      Request starting HTTP/1.1 POST http://localhost:51234/message/negotiate  0\r\ninfo: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler[2]\r\n      Successfully validated the token.\r\ninfo: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[1]\r\n      Authorization was successful.\r\ninfo: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]\r\n      Request finished in 6.1647ms 200 application/json\r\ninfo@@@ OnConnectedAsync is executed\r\n: Microsoft.AspNetCore.SignalR.HubConnectionContext[1]\r\n      Completed connection handshake. Using HubProtocol 'json'.\r\ninfo: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]\r\n      Request starting HTTP/1.1 POST http://localhost:51234/message/negotiate  0\r\ninfo: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler[2]\r\n      Successfully validated the token.\r\ninfo: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[1]\r\n      Authorization was successful.\r\ninfo: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]\r\n      Request finished in 6.8534ms 200 application/json\r\ninfo: Microsoft.AspNetCore.SignalR.HubConnectionContext[1]\r\n      Completed connection handshake. Using HubProtocol 'json'.\r\n@@@ OnConnectedAsync is executed\r\ninfo: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]\r\n      Request starting HTTP/1.1 POST http://localhost:51234/message/negotiate  0\r\ninfo: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler[2]\r\n      Successfully validated the token.\r\ninfo: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[1]\r\n      Authorization was successful.\r\ninfo: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]\r\n      Request finished in 6.5252ms 200 application/json\r\ninfo: Microsoft.AspNetCore.SignalR.HubConnectionContext[1]\r\n      Completed connection handshake. Using HubProtocol 'json'.\r\n@@@ OnConnectedAsync is executed\r\ninfo: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]\r\n      Request starting HTTP/1.1 POST http://localhost:51234/message/negotiate  0\r\ninfo: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler[2]\r\n      Successfully validated the token.\r\ninfo: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[1]\r\n      Authorization was successful.\r\ninfo: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]\r\n      Request finished in 7.1773ms 200 application/json\r\ninfo@@@ OnConnectedAsync is executed\r\n: Microsoft.AspNetCore.SignalR.HubConnectionContext[1]\r\n      Completed connection handshake. Using HubProtocol 'json'.\r\ninfo: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]\r\n      Request starting HTTP/1.1 POST http://localhost:51234/message/negotiate  0\r\ninfo: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler[2]\r\n      Successfully validated the token.\r\ninfo: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[1]\r\n      Authorization was successful.\r\ninfo: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]\r\n      Request finished in 6.7461ms 200 application/json\r\ninfo: Microsoft.AspNetCore.SignalR.HubConnectionContext[1]\r\n      Completed connection handshake. Using HubProtocol 'json'.\r\n@@@ OnConnectedAsync is executed\r\n`\r\n\r\nConnectionId of player 2 is missing:\r\n\r\n![image](https://user-images.githubusercontent.com/5436571/40730122-dcd6dfbc-6425-11e8-9ac2-3f1dd39a106c.png)\r\n"},"comment":{"url":"https://api.github.com/repos/Azure/azure-signalr/issues/comments/394046392","html_url":"https://github.com/Azure/azure-signalr/issues/115#issuecomment-394046392","issue_url":"https://api.github.com/repos/Azure/azure-signalr/issues/115","id":394046392,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NDA0NjM5Mg==","user":{"login":"xscript","id":2300784,"node_id":"MDQ6VXNlcjIzMDA3ODQ=","avatar_url":"https://avatars2.githubusercontent.com/u/2300784?v=4","gravatar_id":"","url":"https://api.github.com/users/xscript","html_url":"https://github.com/xscript","followers_url":"https://api.github.com/users/xscript/followers","following_url":"https://api.github.com/users/xscript/following{/other_user}","gists_url":"https://api.github.com/users/xscript/gists{/gist_id}","starred_url":"https://api.github.com/users/xscript/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xscript/subscriptions","organizations_url":"https://api.github.com/users/xscript/orgs","repos_url":"https://api.github.com/users/xscript/repos","events_url":"https://api.github.com/users/xscript/events{/privacy}","received_events_url":"https://api.github.com/users/xscript/received_events","type":"User","site_admin":false},"created_at":"2018-06-02T01:27:10Z","updated_at":"2018-06-02T01:27:10Z","author_association":"CONTRIBUTOR","body":"@yigitgursoy Could you give me the name of your instance? Also, which region is it in?\r\nYou can email the instance name to `kevinzha at microsoft.com`."}}
{"actor":{"display_login":"xscript"}}