I started playing with the console sample and doing some basic prototyping. As time went on and the project changed I tried moving my prototype client.html file to a webserver and couldn't get my app that worked fine via file:/// to work over
. After stepping through some failed requests I finally realized the problem was due to the "null" origin value specified when calling the WebSocketServer constructor which becomes invalid when the file
is delivered via http.
It seems like a valuable feature would be to add an origin wildcard of "*" which would allow requests from any origin and possibly use that in the samples to avoid the pitfall I ran into. Or if nothing else maybe a comment showing the WebSocketServer
constructor with an http based origin.
It seems like a conditional on the origin test like the following could easily make this feature possible:
if (hasRequiredFields && "ws://"+ClientHandshake.Host == Location && (Origin == "*" || ClientHandshake.Origin == Origin))