2

I have a signalr that worked nice with 4.5 After upgraded to 4.6 it works ok on Win 2008 R2 , but does not work on Windows 2012 .

The error is :

 System.InvalidOperationException: WebSockets is unsupported in the current application configuration. To enable this, set the following configuration switch in Web.config: <system.web> <httpRuntime targetFramework="4.5" /> </system.web> For more information, see http://go.microsoft.com/fwlink/?LinkId=252465. at System.Web.Util.SynchronizationContextUtil.ValidateMode(SynchronizationContextMode currentMode, SynchronizationContextMode requiredMode, String specificErrorMessage) at System.Web.HttpContext.AcceptWebSocketRequest(Func2 userFunc, AspNetWebSocketOptions options) at Microsoft.AspNet.SignalR.Transports.WebSocketTransport.AcceptWebSocketRequest(Func2 callback) at Microsoft.AspNet.SignalR.PersistentConnection.ProcessRequestPostGroupRead(HostContext context, String groupsToken) at Microsoft.AspNet.SignalR.TaskAsyncHelper.FromMethodT1,T2,T3,TResult --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Owin.Mapping.MapMiddleware.d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End(IAsyncResult ar) at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) 

If I add httpRuntime targetFramework="4.5" to web.config , the application won't run at all.

1
  • Is your problem resolved? Commented Oct 16, 2016 at 5:31

2 Answers 2

8

Adding

 <appSettings> <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/> </appSettings> 

To web.config solved the problem

Sign up to request clarification or add additional context in comments.

1 Comment

You should set <httpRuntime targetFramework="4.6" /> to match the project target framework, not 4.5. The error message is a little bit ambiguous, but it was written in that way for historical reasons.
-1

Assuming you are hosting your server in IIS you need to enable websockets in IIS. Here are the details: http://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-websocket-protocol-support

2 Comments

Yes, I am hosting the server in IIS. And WebSocket is enabled.
If WebSockets on IIS was not installed or disabled, the error would be different, and no such exception.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.