Laden...

IIS Revers Proxy + SignalR: Handshake timeout

Erstellt von b0b0nr1 vor 2 Jahren Letzter Beitrag vor 2 Jahren 522 Views
Thema geschlossen
B
b0b0nr1 Themenstarter:in
92 Beiträge seit 2011
vor 2 Jahren
IIS Revers Proxy + SignalR: Handshake timeout

Hi zusammen!

Dieses Problem verdirbt mir echt die ganze Woche.
Ich habe eine Docker Umgebung via Docker-Compose indem ein Container nach außen kommuniziert und den Port 6652 exposed. Darin läuft eine .net Core 3.1 Anwendung mit aktivierten Websockets und SignalR.

Rufe ich https://localhost:6652/ auf und gehe auf die Seite auf der SignalR verwendet wird (Eine Kommentar funktion die die neuen Kommentare in Echtzeit laden soll), funktioniert alles reibungslos.

Daher hab ich vermutet, das Problem muss am ReverseProxy mit ARR3 liegen und habe kurzerhand eine Subdomain in der Hosts Datei eingetragen um das lokal testen zu können.

Gehe ich nun auf die gleiche Seite aber über den Reverse Proxy (IIS10) landet der Handsake im Timeout:


[2022-01-13T18:29:07.232Z] Information: Normalizing '/sockR/hub' to 'https://devlocal.example.com/sockR/hub'.
Utils.js:151 [2022-01-13T18:29:07.233Z] Debug: Starting HubConnection.
Utils.js:151 [2022-01-13T18:29:07.233Z] Debug: Starting connection with transfer format 'Text'.
Utils.js:147 [2022-01-13T18:29:07.342Z] Information: WebSocket connected to wss://devlocal.example.com/sockR/hub.
Utils.js:151 [2022-01-13T18:29:07.342Z] Debug: The HttpConnection connected successfully.
Utils.js:151 [2022-01-13T18:29:07.342Z] Debug: Sending handshake request.
Utils.js:147 [2022-01-13T18:29:07.342Z] Information: Using HubProtocol 'json'.
... 3 Minuten später (solange geht der Timeout)
ERROR Error: Uncaught (in promise): Error: Server timeout elapsed without receiving a message from the server. Error: Server timeout elapsed without receiving a message from the server.

Natürlich habe ich vorher gegooglet und gesehen, dass man zum einen im ARR das Responerbuffering auf 1 setzen soll die Einstellungen hab ich auch so übernommen (Siehe Anhang)

Dann natürlich auch sollte eine WS/WSS Rewrite Rule vorhanden sein. Auch dies habe ich übernommen:


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <urlCompression doStaticCompression="false" doDynamicCompression="false" />
        <rewrite>
            <rules>
                <rule name="WS reverse proxy" stopProcessing="true">
                    <match url="ws://devlocal.example.com" />
                    <conditions>
                        <add input="{CACHE_URL}" pattern="^(.+)://" />
                    </conditions>
                    <action type="Rewrite" url="{C:1}://127.0.0.1:6652" />
                </rule>
                <rule name="WSS reverse proxy" stopProcessing="true">
                    <match url="wss://devlocal.example.com" />
                    <conditions>
                        <add input="{CACHE_URL}" pattern="^(.+)://" />
                    </conditions>
                    <action type="Rewrite" url="{C:1}://127.0.0.1:6652" />
                </rule>

                <rule name="_Inbound_devlocal.example.com.com" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Rewrite" url="{C:1}://localhost:6652/{R:1}" logRewrittenUrl="true" />
                    <conditions logicalGrouping="MatchAny">
                        <add input="{CACHE_URL}" pattern="^(.+)://" />
                        <add input="{HTTP_HOST}" pattern="^devlocal\.example.com\.com$" />
                    </conditions>
                </rule>

            </rules>
            <outboundRules>
                <rule name="_Outboundund_devlocal.example.com.com" stopProcessing="true">
                    <match filterByTags="A, Form, Img, Link, Script" pattern="^http(s)?://localhost:6652/(.*)" />
                    <action type="Rewrite" value="http{R:1}://devlocal.example.com.com/{R:2}" />
                </rule>
            </outboundRules>
        </rewrite>
    </system.webServer>
</configuration>


Und jetzt weiß ich gerade auch nicht weiter.
SignalR is bei mir wie folgt konfiguriert:


 services.AddSignalR(hubOptions =>
            {
                hubOptions.ClientTimeoutInterval = TimeSpan.FromSeconds(240);
                hubOptions.HandshakeTimeout = TimeSpan.FromSeconds(120);
                hubOptions.KeepAliveInterval = TimeSpan.FromSeconds(60);
                hubOptions.EnableDetailedErrors =  true;
                hubOptions.MaximumReceiveMessageSize = 200;
                hubOptions.StreamBufferCapacity = 300;
            });

Der Hub ist wie folgt gemapped:


app.UseEndpoints(api =>
            { 
                api.MapControllers();
                api.MapHub<CommentsHub>("/sockR/hub"); 
            }
);


Das Failed Request Trace Log ist leer, also scheint der Handshake garnicht erst durchzukommen.
Cors erlaubt alle origins fürs Erste.
EDIT:
Websockets Feature ist installiert.
Verwende IIS10 + Docker + ARR3 auf Windows 11.

Hat jemand da eine Idee?

VG

b0b0

16.807 Beiträge seit 2008
vor 2 Jahren
Thema geschlossen