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

How to handle exceptions in IpCamDevice threads #922

Open
lipinskikuba opened this issue Jan 27, 2024 · 0 comments
Open

How to handle exceptions in IpCamDevice threads #922

lipinskikuba opened this issue Jan 27, 2024 · 0 comments

Comments

@lipinskikuba
Copy link

Hi, first of all I would like to say that I am very impressed with your work. This library is very powerful, yet simple and clean, with state of art examples.

I'm using it capture images from webcam. I have problem handling following exception in PushImageReader. It there is problem with connection to camera then after Webcam.open() the following uncaught exception is thrown:

com.github.sarxos.webcam.WebcamException: Cannot download image. Connect to 192.168.0.101:4747 [/192.168.0.101] failed: Połączenie odrzucone
	at com.github.sarxos.webcam.ds.ipcam.IpCamDevice$PushImageReader.request(IpCamDevice.java:83)
	at com.github.sarxos.webcam.ds.ipcam.IpCamDevice$PushImageReader.run(IpCamDevice.java:94)
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to 192.168.0.101:4747 [/192.168.0.101] failed: Połączenie odrzucone
	at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:158)
	at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:376)
	at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)
	at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
	at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
	at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
	at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
	at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
	at com.github.sarxos.webcam.ds.ipcam.IpCamDevice.get(IpCamDevice.java:287)
	at com.github.sarxos.webcam.ds.ipcam.IpCamDevice.access$0(IpCamDevice.java:284)
	at com.github.sarxos.webcam.ds.ipcam.IpCamDevice$PushImageReader.request(IpCamDevice.java:81)
	... 1 more
Caused by: java.net.ConnectException: Połączenie odrzucone
	at java.base/sun.nio.ch.Net.connect0(Native Method)
	at java.base/sun.nio.ch.Net.connect(Net.java:579)
	at java.base/sun.nio.ch.Net.connect(Net.java:568)
	at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:576)
	at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
	at java.base/java.net.Socket.connect(Socket.java:666)
	at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:75)
	at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
	... 13 more

and the whole thread is locked indefinitely on AtomicProcessor.process() line 70 outbound.take()

Is there a build in way to properly handle this kind of exceptions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant