<p>Trying to move my development environment to run on minikube.</p>

<p>The page loads but my page uses websockets on the same port/protocol that the index.html is loaded with (https in this case), and the websockets do no seem to be working correctly.</p>

<p>Here is an example of the correct output when run through nginx / python on my local development box.</p>

<pre><code>127.0.0.1 - - [14/Sep/2018 14:14:35] "GET / HTTP/1.0" 200 -
127.0.0.1 - - [14/Sep/2018 14:14:35] "GET /static/jquery.min.js HTTP/1.0" 200 -
127.0.0.1 - - [14/Sep/2018 14:14:35] "GET /static/socket.io.min.js HTTP/1.0" 200 -
127.0.0.1 - - [14/Sep/2018 14:14:35] "GET /socket.io/?EIO=3&amp;transport=polling&amp;t=MNPIg-N HTTP/1.0" 200 -
127.0.0.1 - - [14/Sep/2018 14:14:35] "GET /favicon.ico HTTP/1.0" 404 -
127.0.0.1 - - [14/Sep/2018 14:14:35] "GET /favicon.ico HTTP/1.0" 404 -
127.0.0.1 - - [14/Sep/2018 14:14:35] "POST /socket.io/?EIO=3&amp;transport=polling&amp;t=MNPIg-o&amp;sid=0570b4fe27f345e9b11858b3acb40a6e HTTP/1.0" 200 -
127.0.0.1 - - [14/Sep/2018 14:14:35] "GET /socket.io/?EIO=3&amp;transport=polling&amp;t=MNPIg-r&amp;sid=0570b4fe27f345e9b11858b3acb40a6e HTTP/1.0" 200 -
127.0.0.1 - - [14/Sep/2018 14:14:35] "POST /socket.io/?EIO=3&amp;transport=polling&amp;t=MNPIg_x&amp;sid=0570b4fe27f345e9b11858b3acb40a6e HTTP/1.0" 200 -
127.0.0.1 - - [14/Sep/2018 14:14:35] "GET /socket.io/?EIO=3&amp;transport=polling&amp;t=MNPIg_w&amp;sid=0570b4fe27f345e9b11858b3acb40a6e HTTP/1.0" 200 -
127.0.0.1 - - [14/Sep/2018 14:14:40] "GET /socket.io/?EIO=3&amp;transport=polling&amp;t=MNPIh0L&amp;sid=0570b4fe27f345e9b11858b3acb40a6e HTTP/1.0" 200 -
127.0.0.1 - - [14/Sep/2018 14:14:45] "GET /socket.io/?EIO=3&amp;transport=polling&amp;t=MNPIiE3&amp;sid=0570b4fe27f345e9b11858b3acb40a6e HTTP/1.0" 200 -
127.0.0.1 - - [14/Sep/2018 14:14:50] "GET /socket.io/?EIO=3&amp;transport=polling&amp;t=MNPIjSI&amp;sid=0570b4fe27f345e9b11858b3acb40a6e HTTP/1.0" 200 -
127.0.0.1 - - [14/Sep/2018 14:14:55] "GET /socket.io/?EIO=3&amp;transport=polling&amp;t=MNPIkgS&amp;sid=0570b4fe27f345e9b11858b3acb40a6e HTTP/1.0" 200 -
</code></pre>

<p>Notice how there is a GET every 5 seconds (that's a timer running on the page)</p>

<p>When running on Kubernetes, The page loads and the timer shows up as if the websocket has worked,  however I show no logs where the websocket is having a GET or POST after the initial one. </p>

<pre><code>192.168.99.1,172.17.0.7 - - [14/Sep/2018 18:24:03] "GET /static/jquery.min.js HTTP/1.1" 304 1210 0.008244
192.168.99.1,172.17.0.7 - - [14/Sep/2018 18:24:03] "GET /static/socket.io.min.js HTTP/1.1" 304 1210 0.009271
(10) accepted ('172.17.0.7', 34444)
192.168.99.1,172.17.0.7 - - [14/Sep/2018 18:24:04] "GET /socket.io/?EIO=3&amp;transport=polling&amp;t=MNPKrsy HTTP/1.1" 200 379 0.003682
(10) accepted ('172.17.0.7', 34446)
192.168.99.1,172.17.0.7 - - [14/Sep/2018 18:24:04] "GET /favicon.ico HTTP/1.1" 404 1314 0.004694
(10) accepted ('172.17.0.7', 34448)
(10) accepted ('172.17.0.7', 34450)
(10) accepted ('172.17.0.7', 34452)
192.168.99.1,172.17.0.7 - - [14/Sep/2018 18:24:04] "GET /socket.io/?EIO=3&amp;transport=polling&amp;t=MNPKrtD&amp;sid=77d4755c524f47c2948b9c36da007b85 HTTP/1.1" 200 210 0.000749
192.168.99.1,172.17.0.7 - - [14/Sep/2018 18:24:04] "POST /socket.io/?EIO=3&amp;transport=polling&amp;t=MNPKrtB&amp;sid=77d4755c524f47c2948b9c36da007b85 HTTP/1.1" 200 194 0.002632
(10) accepted ('172.17.0.7', 34454)
192.168.99.1,172.17.0.7 - - [14/Sep/2018 18:24:04] "GET /favicon.ico HTTP/1.1" 404 1314 0.002388
</code></pre>

<p>The Ingress is setup as follows:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-service
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
    - http:
        paths:
          - path: /
            backend:
              serviceName: websitev2-cluster-ip-service
              servicePort: 8080
</code></pre>

<p>As mentioned before, the websocket does not reside on a different port and it is instanciated in javascript as:</p>

<pre><code>namespace = '/socket';
var socket = io.connect(location.protocol + '//' + document.domain + ':' + location.port + namespace);
</code></pre>

<p>Are there any special requirements to get websockets to work?  I do not believe i need a special route because the URI needs to be sent to the same location as everything else, and on the same port.</p>

<p>EDIT:  MORE DETAILS</p>

<p>My website has a form, that when submitted, executes the following code:</p>

<pre><code>    $('form#job').submit(function(event) {
        var nameValue = JSON.stringify($(event.target).serializeArray());
        console.log(nameValue)
        socket.emit('job_submit', {data: nameValue});
        return false;
    });
</code></pre>

<p>On the python side, I have my socket code, which should get hit once a user clicks the submit button.</p>

<pre><code>@socketio.on('job_submit', namespace='/socket')
def job_submit(message):
    print('recieved job_submit message from client')
    # kick off subjob in celery task
    data = unstringify(message)
    print('data = {0}'.format(data))
    sessiondata = dict(session)
    print('sessiondata = {}'.format(sessiondata))
    subjobstart.delay(sessiondata, request.sid, data)
</code></pre>

<p>In my logs I am not receiving any "recieved job_submit message from client" messages when the submit button is clicked, which means the javascript is trying to send a websocket emit to the python server, but the message is never getting there.</p>

<p>Emits from python to the client page are working as the time is getting updated on the site.</p>

user1601716
<p>So not exactly sure what changed as it worked on test box,  apparently the issue lied in the form validation I was doing.  Once I put in a novalidate option to temporarily bypass the form checking, the form was then able to be submitted and I did not have any websocket issues after all.</p>

<p>Hopefully this post can help someone with the code posted instead.</p>
