Skype4J
Skype4J copied to clipboard
Error while getting messages Error: POLLING_SKYPE java.net.SocketException: Connection reset false
White running the code below for 1minute to 1h (it doesn't happen after a certain time) and receiving some messages the following error starts popping up.
If anyone has any suggestions on how to fix this, it's greatly appreciated.
private static final Logger logger = Logger.getLogger(Skype.class.getName());
public static void main(String[] args) throws Exception {
Skype skype = null;
System.setProperty("com.samczsun.skype4j.debugExceptions", "true");
try {
skype = new LiveLoginSkypeBuilder("[email protected]", "qazxsw123").withAllResources().withExceptionHandler(
(errorSource, error, shutdown) -> {
logger.error("Skype has thrown exception %s", error);
})
.build();
skype.logout();
skype.login();
System.out.println("Logged in");
skype.getEventDispatcher().registerListener(new Listener() {
@EventHandler
public void onMessage(MessageEvent e) {
AtomicReference<String> a = new AtomicReference<>("");
e.getMessage().getChat().getAllParticipants().stream().forEach(participant -> a.set(a + " " + participant.getId()));
System.out.println("Message: " + e.getMessage().getContent() + " sent by " + e.getMessage().getSender().getId() + " Participants:" + a);
}
});
skype.subscribe();
System.out.println("Subscribed");
} catch (ConnectionException e) {
System.out.println(e.getMessage() + ", " + e.getResponseCode() + ", " + e.getResponseMessage());
e.printStackTrace();
}
}
Error: POLLING_SKYPE java.net.SocketException: Connection reset false
ERROR Skype - (TestSkypeNotifications.java:36) false
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:210)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
at sun.security.ssl.InputRecord.read(InputRecord.java:503)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983)
at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:940)
at sun.security.ssl.AppInputStream.read(AppInputStream.java:105)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:735)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:678)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:706)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1587)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:347)
at com.samczsun.skype4j.internal.threads.PollThread.lambda$run$0(PollThread.java:66)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Ps. think that we need to make a small update to PollThread class pendingException value is never reset
if (pendingException != null) {
skype.handleError(ErrorSource.POLLING_SKYPE, pendingException, false);
continue;
}