Closed zhangjicai2016 closed 1 year ago
单线程池调用link.thingscloud.freeswitch.esl.inbound.handler.InboundChannelHandler#sendSyncSingleLineCommand方法时,如果服务端挂了或者重启了一直收不到响应时,这个线程会一直阻塞
public EslMessage sendSyncSingleLineCommand(final String command) { if (isTraceEnabled) { log.trace("sendSyncSingleLineCommand command : {}", command); } SyncCallback callback = new SyncCallback(); syncLock.lock(); try { syncCallbacks.add(callback); channel.writeAndFlush(command + MESSAGE_TERMINATOR); } finally { syncLock.unlock(); } return callback.get(); }
callback.get()方法一直在等待返回,link.thingscloud.freeswitch.esl.inbound.handler.InboundChannelHandler.SyncCallback中的get方法中的latch.await()这个方法是否可以设置一个等待超时
/** * Block waiting for the countdown latch to be released, then return the * associated response object. * * @return msg */ EslMessage get() { try { log.trace("awaiting latch ... "); latch.await(); } catch (InterruptedException e) { throw new RuntimeException(e); } log.trace("returning response [{}]", response); return response; }
由于esl机制问题,同步调用的确存在该问题,建议采用异步调用,上述问题小概率性出现
针对该问题,感觉在连接断开时,将syncCallbacks里面元素都unlock,比较合适
应该不会出现这样的,如果链接断开后InboundChannelHandler对象会销毁的
单线程池调用link.thingscloud.freeswitch.esl.inbound.handler.InboundChannelHandler#sendSyncSingleLineCommand方法时,如果服务端挂了或者重启了一直收不到响应时,这个线程会一直阻塞
callback.get()方法一直在等待返回,link.thingscloud.freeswitch.esl.inbound.handler.InboundChannelHandler.SyncCallback中的get方法中的latch.await()这个方法是否可以设置一个等待超时