1

Anyone know if it is possible to proxy websocket protocol over vagrant share?

I have a node express app with web sockets that I am testing on a smart phone and using vagrant share. The client device gets the html page back fine but errors on making the web socket connection using ws://.

    var host = window.document.location.host.replace(/:.*/, '');
    var port = ':' + (window.document.location.port || 80);

    var ws = new WebSocket('ws://' + host + port);
    ws.onopen = function(evt) { onOpen(evt) };
    ws.onclose = function(evt) { onClose(evt) };
    ws.onmessage = function(evt) { onMessage(evt) };
    ws.onerror = function(evt) { onError(evt) };

When I test on a desktop browser (safari) it behaves the same but works fine when connecting to locally to the vagrant vm (localhost port forwarded).

ewanh
  • 71
  • 1
  • 5
  • Unfortunately I don't have a solution to my question though I do now have an explanation. Web sockets do not work through a proxy see http://stackoverflow.com/questions/2201317/why-dont-current-websocket-client-implementations-support-proxies?rq=1 and it turns put vagrant share is implemented using a local proxy https://www.hashicorp.com/blog/feature-preview-vagrant-1-5-share.html. My work around was to find a colleague who was able to get their phone onto the local wifi and connect to my machine. – ewanh Apr 08 '16 at 08:18

0 Answers0