Closed Primly closed 7 years ago
Hmm you shouldn't have to be actually refreshing the page. Websockets should be handling that - plus it makes it even more annoying for debugging the frontend. There must be some way to connect to azure unless local server is available.
I've done some investigating and it seems I was incorrect in my assumption that the UI page wasn't updating, it is - just very inconsistently, and rarely with new data.
Its seems to be having some trouble connecting to azure socket, getting these errors in console:
WebSocket connection to 'wss://ccarbitrage.azurewebsites.net/socket.io/?EIO=3&transport=websocket&sid=di-0hWUtdAx3CFeoACRC' failed: Error during WebSocket handshake: Unexpected response code: 503
as well as
POST https://ccarbitrage.azurewebsites.net/socket.io/?EIO=3&transport=polling&t=Lra-rGC&sid=Nq_L5Vz9GE3vKg9BACQs 400 (Bad Request)
The result is that over say, a 15 - 20 minute period I'll get maybe 6 successful reloads - hence my original thought that it just wasn't reloading.
Since 503 is the "server unavailable/overloaded" code I'm thinking maybe I'm getting rate limited by Azure? While the 400 code is just Azure flipping me the bird.
But then you aren't connecting to localhost, rather azure? I'll check azure to see if it's getting overloaded.
Yes in this instance I was trying to connect to Azure socket, I'm looking into localhost now to see whats going on with that.
I don't seem to have any problems when I run the site locally - but connected to azure for sockets.
could be I'm just getting throttled for some reason? maybe azure just hates me.
Well I get the same errors but the values still update. Try logging the data from azure on socket results.
Add console.log(results)
after line 234 in script.js
Yes when a connection is successful the values are updated, they were just so similar before it appeared at first glance they were the same.
My issue when trying to connect to the azure socket just seems to be me getting rate limited for whatever reason. In the entire time since my last comment the data reloaded a total of 3 times.
So problem = Azure hates me. Solution = send flowers?
Moving on to my local issue - when setting the socket to http://localhost:3000 it seems like there is never even an attempt to update. The UI loads once and seems to be content with that. Meanwhile if I go to http://localhost:3000 with a browser Socket.io chat it there happily updating data every 10 seconds or so.
Fixed! It was only updating data when the program restarted. This is because socket.io wasn't sending new data.
I've not been able to get the data to refresh on UI page when running locally. This may be due to Azure problem you posted in issues #6, but I'm not sure.
As a workaround I've changed line 107 in script.js from
let socket = io('https://ccarbitrage.azurewebsites.net/');
to
let socket = io("http://localhost:3000");
This keeps my data up to date, but still doesn't get the local index.html page to refresh, so I've added:
<meta http-equiv="refresh" content="25" >
to docs/index.html to force the page to refresh every 25 secs (10 is too annoying).
Obviously not helpful for hosted instance, but may be helpful getting some folks running locally for debug and testing purposes.