Connecting to a virtual machine using Websocket

This can also be seen as a JS question, even though I use a lot of VMware terms.

I am using Websocket to connect to a VM hosted in vSphere and managed by the vCloud director.

Through the vCloud API, I can have a security ticket something similar to cst-xlIs3pP+C/oL/tEgwqvBHv6cBFnTT//VfLNh2kwOjOJItTwfEmVmePhjmJHfV0CisjxqaiQ9AJCNwvfu1zpr1dptvANS9NoIk4TCto7gRsM79R633SS2cIEuvXUAs7KzPoqdjYnSM8BcCttHLz8UbaPPYhjxx1MS2sCfUYovjqtGa9QwkZVBPxrfuPHsJNn3XchTO2h1pm/c/kim2kyu3R3worzcTSZsjGIk+QMWdvfEXc/PNYUGASA0EmP/16IMCltnODY9gQ9ddV0LfXeNKw==-IB8jmkQf1OtvVXZsqoO/cT0Ou93Dx7JlMOTGdQ==--tp-49:4A:E1:31:6B:95:39:AD:47:6D:63:F6:1E:72:F7:D1:B5:65:36:00--

.

So, the Websocket url is a lot like this "wss://10.160.122.169/902;cst-xlIs3pP+C/oL/tEgwqvBHv6cBFnTT//VfLNh2kwOjOJItTwfEmVmePhjmJHfV0CisjxqaiQ9AJCNwvfu1zpr1dptvANS9NoIk4TCto7gRsM79R633SS2cIEuvXUAs7KzPoqdjYnSM8BcCttHLz8UbaPPYhjxx1MS2sCfUYovjqtGa9QwkZVBPxrfuPHsJNn3XchTO2h1pm/c/kim2kyu3R3worzcTSZsjGIk+QMWdvfEXc/PNYUGASA0EmP/16IMCltnODY9gQ9ddV0LfXeNKw==-IB8jmkQf1OtvVXZsqoO/cT0Ou93Dx7JlMOTGdQ==--tp-49:4A:E1:31:6B:95:39:AD:47:6D:63:F6:1E:72:F7:D1:B5:65:36:00--"

, in that 902 is the port returned by the vCloud director.

After I have created this website, my function onopen

is called, does this mean that the connection is established? However, after one or two seconds the websocket is called onclose

. Does this say the server is closing the connection? Event ID 1006 ...

How can I debug more of this problem?

+3


source to share


1 answer


The rounded code 1006 means the socket was simply "dropped" (TCP disabled) without receiving a WebSocket protocol private frame ( https://tools.ietf.org/html/rfc6455 section 7.1.5)

There are several reasons why this can happen - it could be things like slick network infrastructure or even fuzzy implementations of parts of the network socket protocol layers.



However, since you are using an SSL connection, another possibility is to disagree with the certificates used. Perhaps if the server side certificate is self-signed and you haven't installed it in the browser that initiated the connection (or it uses some kind of internal CA and this CA is not recognized). Unfortunately, most browsers don't give much information when they encounter bad certificates on a websocket - no "you want to trust this certificate" (as opposed to https).

You should also check if you have a ticket that needs to be URL encoded - it is possible that the '=' characters in this string need to be replaced with% 3d (URL encoded). Although I honestly don't remember if this requires a server side web descriptor handler.

+3


source







All Articles