Edge DTLS Handshake fails to complete (ORTC) - javascript

I'm trying to use Edge's ORTC in order to have real-time communication with other web browsers. I've successfuly made this work using peer-to-peer connections but I'm having problems after adding a gateway in between.
The DTLS handshake for some reason fails when I start the call using Edge (controlling), I've turn on wireshark to see if any DTLS messages were being executed but none was "sniffed" (this can be an wireshark issue though). If I answer from Edge (controlled) the connection works (even with the gateway in between).
It's important to notice that the ICE Connection is successfuly established in every case, it seems that by some reason Edge doesn't initiate the DTLS handshake and I can't understand what is the trigger point (I even get the "checking" status on the "ondtlsstatechange" event for the dtls transport object). After about 30 seconds the failed event triggers!
Someone else is having this problem? What could be creating this issue?
Thanks..

I've found a solution..
Well, basically my Gateway was a passive peer and I was starting the DTLS transport with the role "auto", and since the Edge was the "controlling" it automatically sets it as a "server". So basically both ends were "servers" and no DTLS Handshake was being sent. Setting the remote role as "server" solved the issue :)
remoteDtlsParameters.role = "server";
dtlsTransport.start(remoteDtlsParameters);
More info about the remote parameters can be found here:
https://msdn.microsoft.com/en-us/library/mt502488(v=vs.85).aspx

Related

Web application using websockets “Could not establish connection. Receiving end does not exist."

Java server, javascript client, no special libraries, plain text HTTP/1.1 and websocket connections.
Server side written (in Eclipse) using JDK 16 and a websocket jar found in Tomcat, version 10.0.2. (Many permutations of other JDKs and websocket jars have also been tried.)
Two web applications. Tomcat 10.0.2 on PC, 10.0.7 on server. Both apps run on Windows 10. Deployed to a Ubuntu 20.04 server. Both programs display the initial HTTP data. One program gets a websocket connection and works, the other fails to get the websocket connection. Both use the same code to calculate the target URL for the websocket connection:
window.onload = function() {
var target = "ws://" + location.host + "/[context]/[endpoint]";
console.log("target: " + target);
try {
if ('WebSocket' in window) {
socket = new WebSocket(target);
} else if ('MozWebSocket' in window) {
socket = new MozWebSocket(target);
} else {
alert('WebSocket is not supported by this browser.');
return;
}
} catch (e) {
console.log("websocket connection exception: " + e.description);
}
...
Where only [context] and [endpoint] differ. Recall that these URLs work on a PC. I believe they are “well-formed”/valid.
Results for the web app that fails:
Firefox:
uncaught exception: Could not establish connection. Receiving end does not exist.
GET ws://35.xxx.xx.xx:8080/Memory/MemoryEndpoint[HTTP/1.1 404 70ms]
Firefox can’t establish a connection to the server at ws://35.xxx.xx.xx:8080/Memory/MemoryEndpoint.
Chrome:
Error handling response: TypeError: Cannot read property 'encrypt' of undefined
at Object.13 (chrome-extension://bkdgflcldnnnapblkhphbgpggdiikppg/public/js/content-scripts/autofill.js:1427:33)
. . .
game.js:31 WebSocket connection to 'ws://xxx.xx.xx.xx:8080/Memory/MemoryEndpoint' failed:
Chrome continues for many lines regarding the 'encrypt' undefined issue. I have no idea what that is about but it might be very relevant. The last line above implies that some reason for the failure might be given on the next line, but it is empty.
Neither browser logs the expected exception text beginning with: "websocket connection exception:".
Tomcat log files are all clean except for some curious entries in localhost__access_log such as:
209.90.225.218 - - [11/Jul/2021:00:43:33 +0000] "HEAD /robots.txt HTTP/1.0" 404 -
And others mentioning /invoker/readonly, /login, /jenkins/login, /nifi/.
The fact that both programs do return results from the Tomcat server tells me that permissions on ports etc are all sufficient. I've also dug into netstat results and the like, reviewed firewall settings, read many many articles and requests for help. (Probably irrelevant because Tomcat does return expected HTTP/1.1 data.) No luck.
I need this program to work. I would pay a cash reward for a solution to this by 07-16-2021, though I don't know how to discretely negotiate that. :-(
Problem resolved, though I don't understand the cause. Recall: the web application ran fine on development PC deployed to Tomcat version 10.0.2, for various JDKs, websocket libraries (including one found in the Tomcat 10.0.7 that had been installed on the VM). The app failed on the Ubuntu VM. A friend installed Tomcat 10.0.8 in the VM. Presto! websockets work.

Receiving responses to responses from messages broadcast to 255.255.255.255 on Node.js

I am sending broadcast to zero network [255.255.255.255] (e.g. DHCP or any other specific protocol, which cannot use any specific broadcast address and limited to local only) from the specific interface and expecting to get response.
So as part as result of Bind() for dgram callback, i am trying to add my local ip to this broadcast group
socket.setMulticastTTL(128);
socket.setBroadcast(true);
socket.addMembership(BROAD_ADDRESS,ip);
socket.setMulticastLoopback(true);
and getting error.
throw errnoException(err, 'addMembership');
^
Error: addMembership EINVAL
I would assume, that since this is local address it is already a part of zero network group (like in Windows). But the problem is that without using addMembership call, i can see response traffic coming to the interface, but NodeJS client is not able to receive it.
Everything works fine (i am able to send messages and get responses, when using any other broadcast address), but not this specific one.
This also not works with network specific addresses (e.g. for 10.1.10.0/24 network with broadcast to 10.1.10.255)
So, how to receive responses to broadcast messages to zero network on linux?

Network Error 12152: WebSockets in Edge and IE 11

I have a site using websockets secure (WSS) and works very well in chrome.
Testing in IE and Edge also works however in the browser console I get Network Error 12152 which will also trigger the websocket.addEventListener("error",function(){}) if implemented.
Everything actually works I just get this error which doesnt seem to break anything.
Error is triggered When socket is closed from Browser Side
Headers in EDGE
More Info: Example of the code I use
//connect via wss then
ws.addEventListener("error",function(event){ // this hits when Socket is closed})
ws.addEventListener("open",function(){
ws.addEventListener("message",function(event){
//do stuff
ws.Close()
})
})
To Confirm the problem further
I went to https://www.websocket.org/echo.html in edge the site which has the ability to test websocket connections. I made it connect to my server. which opens the connection without a problem. However in just the same way I have been getting problems with my code. This site also throws an error when I click the disconnect button. See Image Below. Is this a bug in IE/Edge?
My Server isnt disconnecting correctly?
I use the above site with the default destination (Their websocket server) and not mine. There are no errors. But when connecting to mine on disconnect there are errors.
What could be the problem?
Thanks
Looking at the Microsoft KB article you are not givng back the expected response/headers on connection setup
From the microsoft knowledge base
12152 ERROR_HTTP_INVALID_SERVER_RESPONSE
The server response could not be parsed.
From the developper docs of mozilla if you look at the Server Handshake Response part
When it gets this request, the server should send a pretty odd-looking (but still HTTP) response that looks like this (remember each header ends with \r\n and put an extra \r\n after the last one):
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
So, I suggest you check your headers and see which responses you are sending on the handshake, so you keep in line with protocols.
I have fixed the same error in IE browsers. Check the capitalization of the first letter of websocket.
Non IE browser:
Upgrade: **w**ebsocket
IE browser:
Upgrade: **W**ebsocket

chrome getting new Error during WebSocket handshake

have node.js websockets running through haproxy, and has been running successfully for several months.
now now giving error
Error during WebSocket handshake: 'Connection' header value is not 'Upgrade'
same code / setup is still working on development computer
any ideas / suggestions more than appreciated!
firefox works ok! chrome errors from main server, but works correctly local
There is something terribly concerning here with this error message. The "Connection" header value should not be "Upgrade" but should contain "Upgrade". "Connection" is an HTTP header field which is hop-by-hop and may contain multiple tokens, including Upgrade, but also a number of other ones. This is in RFC6455 page 17 :
" 5. The request MUST contain an |Upgrade| header field whose value MUST include the "websocket" keyword."
So I think that something is wrong in the server software, or at least in the error message. You should definitely take a network capture to be sure.

Update client status to server on "onbeforeunload" event

I have a flash application that needs to send a http request to the server which will disconnect the existing session immediately. I have a tried a few options but none is reliable.
Option #1: On "onbeforeunload" event send a http request from inside the flash applications. Fallacy: This does not work because as soon as the browser is closed the flash player unloads the app and hence the communication breaks.
Option #2: On "onbeforeunload" event send a http request using XMLHTTPRequest in ajax. This works fine in IE but doesnt work in Firefox. When i debugged the http req in httpfox it threw "NS_BINDING_ABORTED" error which i think means that request was cancelled due to page unload.
Note that if i use an alert box, the requests are getting sent in both the options. But i cant use alert boxes. Is there any other way to do so ? or maybe kill the alert box after a timeout ?
It should not be the client's responsibility to tell the server it is disconnecting. You can make the client ping the server regularly to tell it it is still alive, or you could open an never-ending http request (comet-style), and fire the event when the tcp connection is broken.
In PHP it would look somehthing like this: (Not tested)
<?php
// Run script until aborted.
ignore_user_abort(true);
set_time_limit(0);
while(connection_status() == CONNECTION_NORMAL) {
sleep(1);
}
// The connection was lost, so do something.
onLostConnection();
?>
Anyway what was happening was that i was sending a crossdomain xmlhttprequest which is not allowed. see here, http://developer.yahoo.com/javascript/howto-proxy.html . I just fixed the urls and it worked in firefox as well.

Categories

Resources