Skip to content

Commit

Permalink
fix: mjpeg server sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouYixun committed Nov 25, 2022
1 parent 99e24dd commit f11dcbd
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,24 @@ public void onOpen(Session session, @PathParam("key") String secretKey,
return;
}
MjpegInputStream mjpegInputStream = null;
try {
mjpegInputStream = new MjpegInputStream(url.openStream());
} catch (IOException e) {
log.info(e.getMessage());
int waitMjpeg = 0;
while (mjpegInputStream == null) {
try {
mjpegInputStream = new MjpegInputStream(url.openStream());
} catch (IOException e) {
log.info(e.getMessage());
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
log.info(e.getMessage());
return;
}
waitMjpeg++;
if (waitMjpeg >= 20) {
log.info("mjpeg server connect fail");
return;
}
}
ByteBuffer bufferedImage;
int i = 0;
Expand Down

0 comments on commit f11dcbd

Please sign in to comment.