<p>I have a autobahn twisted websocket running in python which is working in a dev vm correctly but I have been unable to get working when the server is running in openshift.</p>

<p>Here is the shortened code which works for me in a vm.</p>

<pre><code>from autobahn.twisted.websocket import WebSocketServerProtocol, WebSocketServerFactory, listenWS
from autobahn.twisted.resource import WebSocketResource

class MyServerProtocol(WebSocketServerProtocol):
    def onConnect(self, request):
        stuff...
    def onOpen(self):
        stuff...
    def onMessage(self,payload):
        stuff...


factory = WebSocketServerFactory(u"ws://0.0.0.0:8080")
factory.protocol = MyServerProtocol
resource = WebSocketResource(factory)

root = File(".")
root.putChild(b"ws", resource)
site = Site(root)

reactor.listenTCP(8080, site)
reactor.run()
</code></pre>

<p>The connection part of the client is as follows:</p>

<pre><code>var wsuri;
var hostname = window.document.location.hostname;
wsuri = "ws://" + hostname + ":8080/ws";

if ("WebSocket" in window) {
    sock = new WebSocket(wsuri);
} else if ("MozWebSocket" in window) {
    sock = new MozWebSocket(wsuri);
} else {
    log("Browser does not support WebSocket!");
    window.location = "http://autobahn.ws/unsupportedbrowser";
}
</code></pre>

<p>The openshift configuration is as follows:</p>

<p>1 pod running with app.py listening on port 8080 
tls not enabled
I have a non-tls route 8080 > 8080.</p>

<p>Firefox gives the following message in the console:</p>

<pre><code>Firefox can’t establish a connection to the server at ws://openshiftprovidedurl.net:8080/ws.
</code></pre>

<p>when I use wscat to connect to the websocket.</p>

<pre><code>wscat -c ws://openshiftprovidedurl.net/ws
</code></pre>

<p>I get the following error:</p>

<pre><code>error: Error: unexpected server response (400)
</code></pre>

<p>and the application log in openshift shows the following:</p>

<pre><code>2018-04-03 01:14:24+0000 [-] failing WebSocket opening handshake ('missing port in HTTP Host header 'openshiftprovidedurl.net' and server runs on non-standard port 8080 (wss = False)')
2018-04-03 01:14:24+0000 [-] dropping connection to peer tcp4:173.21.2.1:38940 with abort=False: missing port in HTTP Host header 'openshiftprovidedurl.net' and server runs on non-standard port 8080 (wss = False)
2018-04-03 01:14:24+0000 [-] WebSocket connection closed: connection was closed uncleanly (missing port in HTTP Host header 'openshiftprovidedurl.net' and server runs on non-standard port 8080 (wss = False))
</code></pre>

<p>Any assistance would be appreciated!</p>

<p>Graham Dumpleton hit the nail on the head, I modified the code from </p>

<pre><code>factory = WebSocketServerFactory(u"ws://0.0.0.0:8080")
</code></pre>

<p>to </p>

<pre><code>factory = WebSocketServerFactory(u"ws://0.0.0.0:8080", externalPort=80)
</code></pre>

<p>and it corrected the issue.  I had to modify my index to point to the correct websocket but I am now able to connect.</p>

<p>Thanks!</p>
