0

任何人都知道如何在向 SMSC 提交消息 (submit_sm) 时设置超时?我尝试将接收超时 (session.getReceiver().setReceiveTimeout) 设置为 6 秒,但大约 30 秒后我仍然得到空响应。

以下是我设置的超时:

  • session.getReceiver().setReceiveTimeout(6000)
  • session.getReceiver().setQueueTimeout(6000)
  • TCPIPConnection.setCommsTimeout(5000)
  • TCPIPConnection.setReceiveTimeout(5000)

目前我正在使用 OpenSMPP

蒂亚:)

4

1 回答 1

0

制定新的未来任务

public static class SubmitSMTask implements Callable<SubmitSMResp>{
    SubmitSM smRequest;
    Session sessionSend;

    public SubmitSMTask(Session sessionSend, SubmitSM smRequest) {
        this.sessionSend = sessionSend;
        this.smRequest = smRequest;
    }

    @Override
    public SubmitSMResp call() throws Exception {
        SubmitSMResp response = sessionSend.submit(smRequest);
        return response;
    }
}

然后调用它。我用 100 毫秒作为超时

ExecutorService executor = Executors.newSingleThreadExecutor();
Future<SubmitSMResp> future = executor.submit(new SubmitSMTask(sessionSend, smRequest));
SubmitSMResp response = future.get(100, TimeUnit.MILLISECONDS);
smsId = response.getMessageId();
于 2019-04-12T11:06:36.050 回答