Azure / azure-relay-dotnet

☁️ .NET Standard client library for Azure Relay Hybrid Connections

Home Page:https://docs.microsoft.com/en-us/azure/service-bus-relay/relay-what-is-it

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Windows 7 doesn't support WebSocket.dll] "simple" sample result in a RelayException

pmhsfelix opened this issue · comments

I'm trying out the "simple" sample and when I run the server I get a RelayException with an inner exception stating The remote server returned an error: (500) Internal Server Error. All the four parameters (namespace, endpoint path, policy name and policy key seem to be ok - if I change any of them the error is and appropriate for the change.

Will you include the full output of RelayException.ToString()? (Ideally that would have a TrackingId, Timestamp, and include the address, i.e. "sb://YOURNAMESPACE.servicebus.windows.net/YOURENDPOINT").

InternalServerError. TrackingId:076fd61e-e290-4ce8-8943-1092806c95f0_G26, SystemTracker:sb://pmhsfelix.servicebus.windows.net/hybrid0, Timestamp:12/5/2016 7:14:20 PM

That TrackingId is associated with this exception in the cloud side traces:

ActivityId = 076fd61e-e290-4ce8-8943-1092806c95f0
System.Net.WebSockets.WebSocketException (0x80004005): The ValidateWebSocketHeaders operation was called on an incoming WebSocket request without required 'Sec-WebSocket-Version' header.

Since the "simple" sample just uses HybridConnectionListener I'm curious what version of Microsoft.Azure.Relay.dll is being used. If you make sure that the latest nuget package is being used by your projects (Microsoft.Azure.Relay 0.1.2-preview) and run with that do you still get an internal server error? (Verify that when you select the "Microsoft.Azure.Relay" entry under "References" in Solution Explorer it shows a path like: "*\simple\packages\Microsoft.Azure.Relay.0.1.2-preview\lib\net45\Microsoft.Azure.Relay.dll").

I didn't managed to build the "simple" sample directly due to the problem reported in #31. I removed the DLL that was being loaded directly from a "strange" path and installed Microsoft.Azure.Relay 0.1.2-preview.

Here is the content of my packages.config

<packages>
  <package id="Microsoft.Azure.Relay" version="0.1.2-preview" targetFramework="net452" />
</packages>
  • You still get the InternalServerError exception with the latest 0.1.2-preview package?
  • Does the exception occur when trying to run the Server.exe?
  • What Operating System are you running this on?
  • Have you made any code or project changes at all that might affect the behavior?
  • Is the sample running as a 32 or 64 bit process?
  • Would it be possible for you to reproduce the issue with a debugger attached, stop at the very first first-chance exception after calling listener.OpenAsync(), and get a memory dump of the process? (In VS go to the Debug Menu -> Save Dump As...) I can give you a hybrid connection and keyname/keyvalue pair if you'd like. Contact me at dstucki (at) microsoft.com if you want me to do this.

You still get the InternalServerError exception with the latest 0.1.2-preview package?

Yes

Does the exception occur when trying to run the Server.exe?

Yes

What Operating System are you running this on?

Windows 7 Professional SP1

Have you made any code or project changes at all that might affect the behavior?

No

Is the sample running as a 32 or 64 bit process?

Build is set to "Any CPU"

Would it be possible for you to reproduce the issue with a debugger attached, stop at the very first first-chance exception after calling listener.OpenAsync(), and get a memory dump of the process? (In VS go to the Debug Menu -> Save Dump As...) I can give you a hybrid connection and keyname/keyvalue pair if you'd like. Contact me at dstucki (at) microsoft.com if you want me to do this.

I've the memory dump and it's ~160MB. What's the best way to send it to you?

This is most likely a Windows 7 compatibility issue then. I need to do some investigation into this. I don't think I need the memory dump at this time unless it should happen to work on Windows 7 for me.

At this point we don't really support Windows 7. We're building on top of the .NET 4.5 System.Net.WebSockets.ClientWebSocket which also doesn't support Windows 7 (websocket.dll support from the OS is not there).

However, you may be able to get something working on your own by doing something like this example branch/commit:
Branch: https://github.com/dstuckims/azure-relay-dotnet/tree/PossibleWorkAroundForWindows7
Commit: https://github.com/dstuckims/azure-relay-dotnet/commit/ab4628939d6aba0c5904005e839ec62e04b2647f

I took the ManagedWebSocket class from .NET Core (they actually only use this implementation on *nix) and hacked it to build with .NET 4.5 (and simply removed the .NET Core build for the mean time, I wasn't trying to make it cross-compile for all platforms). This hasn't been tested but you may be able to take this example branch/commit, build your own copy of Microsoft.Azure.Relay.dll and get it to work on Windows 7 (you'll probably want to change the signing key and turn off delay signing on the library you build since it's not coming from Microsoft build labs). This is very unofficial at this point but I'm sharing it in case it might help.

I have now tried the approach I mentioned above with the changes in that private branch of mine.

  1. I built a new Microsoft.Azure.Relay.dll with those changes in https://github.com/dstuckims/azure-relay-dotnet/commit/ab4628939d6aba0c5904005e839ec62e04b2647f.
  2. Updated the Simple sample to reference that newly built Microsoft.Azure.Relay.dll
  3. Skipped verification on the Windows 7 machine by adding this registry entry:
    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\StrongName\Verification\Microsoft.Azure.Relay,31BF3856AD364E35]
    (or you could run "sn.exe -Vr Microsoft.Azure.Relay.dll", but I didn't have sn.exe on that machine at the time).

Then the "simple" sample server.exe and client.exe worked on Windows 7.

Just wanted to confirm I used the method described for updating Microsoft.Azure.Relay.dll, and it successfully worked for using Relay on Windows 7. Thanks

Could this modification in ab46289 be ported to the 1.0.0 release of Azure.Relay? I'd like to use this on Win7 and would prefer using the 1.0.0 version instead of a pre-release version. I have tried myself but have not had any luck getting a clean build yet. Thanks very much

Beating a dead horse? But 2.0.1 works fine on Windows 7 as long as using the netstandard2.0 assembly (as it is using managed websockets I assume) while net451 assembly does not work (as it is using native websockets I assume, and you get platform not supported).

@jburnsman do you have that dll? I haven't been able to build that branch