[HtmlUnit] [htmlunit:bugs] #2019 Unwanted WebSocket Connection

RBRi via HtmlUnit-develop <[email protected]> Thu, 01 Aug 2019 17:32:29 -0000
Newsgroups gmane.comp.java.htmlunit.devel
Message-ID </p/htmlunit/bugs/2019/5d846b5a1d5f25ee0004d2f70bb6504a41b4f8a0.bugs@htmlunit.p.sourceforge.net>
This is a multi-part message in MIME format.
--===============7667116130869176103==
Content-Type: multipart/related;
 boundary="===============1043474884487055220=="

This is a multi-part message in MIME format.
--===============1043474884487055220==
Content-Type: multipart/alternative;
 boundary="===============0611591342383986416=="
MIME-Version: 1.0

--===============0611591342383986416==
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit

- **status**: open --> closed



---

** [bugs:#2019] Unwanted WebSocket Connection**

**Status:** closed
**Group:** 2.35.0
**Created:** Fri Jul 05, 2019 10:55 PM UTC by Ahsan Kazmi
**Last Updated:** Thu Aug 01, 2019 05:32 PM UTC
**Owner:** nobody


I tried searching for a solution but was unable to find how to prevent connection to a websocket. I only need to read html that is rendered through javascript, and I am able to do that fine. 

The following is my code:
            webClient = new WebClient(BrowserVersion.CHROME);
			webClient.getOptions().setUseInsecureSSL(true);
			webClient.getOptions().setJavaScriptEnabled(true);
			page = webClient.getPage(address);
			webClient.waitForBackgroundJavaScript(3000);
			List<DomElement> statusElementList = page.getByXPath("//span[contains(@class, 'state-title')]");
			String status = statusElementList.get(0).getFirstChild().toString();
           
The following is the stacktrace I am seeing:

 websocket error             info WebConsole.java  : 422 
2019-07-05 22:44:09 [UTC] [HttpClient@1433621164-98] INFO  c.g.htmlunit.WebConsole    websocket closed.            
 ERROR c.g.h.javascript.host.WebSocket      - [trueEDGE] Customer: qa-uss, Device:  connect error for url 'wss://192.168.44.202/statusd':              run WebSocket.java   : 179 

java.util.concurrent.ExecutionException: org.eclipse.jetty.websocket.api.UpgradeException: 400 Bad Request
	at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
	at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895)
	at com.gargoylesoftware.htmlunit.javascript.host.WebSocket$1.run(WebSocket.java:175)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591)
	at java.lang.Thread.run(Thread.java:748)
Caused by: org.eclipse.jetty.websocket.api.UpgradeException: 400 Bad Request
	at org.eclipse.jetty.websocket.client.WebSocketUpgradeRequest.onComplete(WebSocketUpgradeRequest.java:520)
	at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:193)
	at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:185)
	at org.eclipse.jetty.client.HttpReceiver.terminateResponse(HttpReceiver.java:459)
	at org.eclipse.jetty.client.HttpReceiver.responseSuccess(HttpReceiver.java:405)
	at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.messageComplete(HttpReceiverOverHTTP.java:297)
	at org.eclipse.jetty.http.HttpParser.handleContentMessage(HttpParser.java:606)
	at org.eclipse.jetty.http.HttpParser.parseContent(HttpParser.java:1536)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:1384)
	at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.parse(HttpReceiverOverHTTP.java:170)
	at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.process(HttpReceiverOverHTTP.java:131)
	at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.receive(HttpReceiverOverHTTP.java:70)
	at org.eclipse.jetty.client.http.HttpChannelOverHTTP.receive(HttpChannelOverHTTP.java:130)
	at org.eclipse.jetty.client.http.HttpConnectionOverHTTP.onFillable(HttpConnectionOverHTTP.java:116)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
	at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:289)
	at org.eclipse.jetty.io.ssl.SslConnection$3.succeeded(SslConnection.java:149)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
	at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
	at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
	at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:199)
	... 3 common frames omitted



---

Sent from sourceforge.net because [email protected] is subscribed to https://sourceforge.net/p/htmlunit/bugs/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/htmlunit/admin/bugs/options.  Or, if this is a mailing list, you can unsubscribe from the mailing list.
--===============0611591342383986416==
MIME-Version: 1.0
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: 7bit

<div class="markdown_content"><ul>
<li><strong>status</strong>: open --&gt; closed</li>
</ul>
<hr/>
<p><strong> <a class="alink strikethrough" href="https://sourceforge.net/p/htmlunit/bugs/2019/">[bugs:#2019]</a> Unwanted WebSocket Connection</strong></p>
<p><strong>Status:</strong> closed<br/>
<strong>Group:</strong> 2.35.0<br/>
<strong>Created:</strong> Fri Jul 05, 2019 10:55 PM UTC by Ahsan Kazmi<br/>
<strong>Last Updated:</strong> Thu Aug 01, 2019 05:32 PM UTC<br/>
<strong>Owner:</strong> nobody</p>
<p>I tried searching for a solution but was unable to find how to prevent connection to a websocket. I only need to read html that is rendered through javascript, and I am able to do that fine. </p>
<p>The following is my code:<br/>
            webClient = new WebClient(BrowserVersion.CHROME);<br/>
            webClient.getOptions().setUseInsecureSSL(true);<br/>
            webClient.getOptions().setJavaScriptEnabled(true);<br/>
            page = webClient.getPage(address);<br/>
            webClient.waitForBackgroundJavaScript(3000);<br/>
            List&lt;domelement&gt; statusElementList = page.getByXPath("//span<span>[contains(@class, 'state-title')]</span>");<br/>
            String status = statusElementList.get(0).getFirstChild().toString();&lt;/domelement&gt;</p>
<p>The following is the stacktrace I am seeing:</p>
<p>websocket error             info WebConsole.java  : 422 <br/>
2019-07-05 22:44:09 <span>[UTC]</span> <span>[HttpClient@1433621164-98]</span> INFO  c.g.htmlunit.WebConsole    websocket closed.          <br/>
 ERROR c.g.h.javascript.host.WebSocket      - <span>[trueEDGE]</span> Customer: qa-uss, Device:  connect error for url 'wss://192.168.44.202/statusd':              run WebSocket.java   : 179 </p>
<p>java.util.concurrent.ExecutionException: org.eclipse.jetty.websocket.api.UpgradeException: 400 Bad Request<br/>
    at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)<br/>
    at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895)<br/>
    at com.gargoylesoftware.htmlunit.javascript.host.WebSocket$1.run(WebSocket.java:175)<br/>
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673)<br/>
    at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591)<br/>
    at java.lang.Thread.run(Thread.java:748)<br/>
Caused by: org.eclipse.jetty.websocket.api.UpgradeException: 400 Bad Request<br/>
    at org.eclipse.jetty.websocket.client.WebSocketUpgradeRequest.onComplete(WebSocketUpgradeRequest.java:520)<br/>
    at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:193)<br/>
    at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:185)<br/>
    at org.eclipse.jetty.client.HttpReceiver.terminateResponse(HttpReceiver.java:459)<br/>
    at org.eclipse.jetty.client.HttpReceiver.responseSuccess(HttpReceiver.java:405)<br/>
    at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.messageComplete(HttpReceiverOverHTTP.java:297)<br/>
    at org.eclipse.jetty.http.HttpParser.handleContentMessage(HttpParser.java:606)<br/>
    at org.eclipse.jetty.http.HttpParser.parseContent(HttpParser.java:1536)<br/>
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:1384)<br/>
    at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.parse(HttpReceiverOverHTTP.java:170)<br/>
    at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.process(HttpReceiverOverHTTP.java:131)<br/>
    at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.receive(HttpReceiverOverHTTP.java:70)<br/>
    at org.eclipse.jetty.client.http.HttpChannelOverHTTP.receive(HttpChannelOverHTTP.java:130)<br/>
    at org.eclipse.jetty.client.http.HttpConnectionOverHTTP.onFillable(HttpConnectionOverHTTP.java:116)<br/>
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)<br/>
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)<br/>
    at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:289)<br/>
    at org.eclipse.jetty.io.ssl.SslConnection$3.succeeded(SslConnection.java:149)<br/>
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)<br/>
    at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)<br/>
    at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)<br/>
    at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)<br/>
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)<br/>
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:199)<br/>
    ... 3 common frames omitted</p>
<hr/>
<p>Sent from sourceforge.net because [email protected] is subscribed to <a href="https://sourceforge.net/p/htmlunit/bugs/">https://sourceforge.net/p/htmlunit/bugs/</a></p>
<p>To unsubscribe from further messages, a project admin can change settings at <a href="https://sourceforge.net/p/htmlunit/admin/bugs/options.">https://sourceforge.net/p/htmlunit/admin/bugs/options.</a>  Or, if this is a mailing list, you can unsubscribe from the mailing list.</p></div>
--===============0611591342383986416==--
--===============1043474884487055220==--


--===============7667116130869176103==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============7667116130869176103==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
HtmlUnit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop

--===============7667116130869176103==--