Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOException wrapped in InternalError not handled properly #905

Closed
PearSlice opened this issue Jun 12, 2019 · 1 comment · Fixed by #901
Closed

IOException wrapped in InternalError not handled properly #905

PearSlice opened this issue Jun 12, 2019 · 1 comment · Fixed by #901

Comments

@PearSlice
Copy link
Contributor

Describe the bug
The call to socket.connect(...) at WebSocketClient:436 can throw a java.lang.InternalError that is currently not handled in the enclosing try/catch as it extends java.lang.Error and not java.lang.Exception

This InternalError wraps a java.lang.IOException that contains useful information to the websocket engine to hande this case.

To Reproduce
Steps to reproduce the behavior:

  1. Install a proxy, i.e. squid
  2. Make it deny connections

Example application to reproduce the issue
Use the previously installed proxy in the ProxyClientExample

Expected behavior
An IOException handled by the underlying websocket engine

Debug log

Exception in thread "WebSocketConnectReadThread-11" java.lang.InternalError: Should not reach here
	at java.net.HttpConnectSocketImpl.doTunneling(HttpConnectSocketImpl.java:181)
	at java.net.HttpConnectSocketImpl.doTunnel(HttpConnectSocketImpl.java:168)
	at java.net.HttpConnectSocketImpl.access$200(HttpConnectSocketImpl.java:44)
	at java.net.HttpConnectSocketImpl$2.run(HttpConnectSocketImpl.java:151)
	at java.net.HttpConnectSocketImpl$2.run(HttpConnectSocketImpl.java:149)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.HttpConnectSocketImpl.privilegedDoTunnel(HttpConnectSocketImpl.java:148)
	at java.net.HttpConnectSocketImpl.connect(HttpConnectSocketImpl.java:111)
	at java.net.Socket.connect(Socket.java:589)
	at org.java_websocket.client.WebSocketClient.run(WebSocketClient.java:436)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at java.net.HttpConnectSocketImpl.doTunneling(HttpConnectSocketImpl.java:179)
	... 10 more
Caused by: java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 403 Forbidden"
	at sun.net.www.protocol.http.HttpURLConnection.doTunneling(HttpURLConnection.java:2142)
	... 15 more

Environment(please complete the following information):

  • Version used: 1.4.0
  • Java version: 1.8.0_181
  • Operating System and version: Ubuntu 16.04 LTS
  • Endpoint Name and version: "ws://echo.websocket.org"
  • Link to your project: ProxyClientExample in the examples folder

Additional context
This is my first time reporting an issue on a open source project.
I'm open to feedback :)

@marci4
Copy link
Collaborator

marci4 commented Jun 12, 2019

Hello @PearSlice,

thank you for creating this bug report!

Looks good :)

Best regards,
Marcel

@marci4 marci4 added this to the Release 1.4.1 milestone Jun 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants