private void destroySession() { if (smppSession != null) { LOGGER.info("Cleaning up SMPP session... "); smppSession.destroy(); smppSession = null; } }
@Override public synchronized void sendMessageSync(String destAddress, String message, boolean command) throws MessageException, InterruptedException, IllegalStateException { if (getSession() != null && getSession().isBound()) { try { SubmitSm submit = new SubmitSm(); : new Address(sourceTon, sourceNpi, sourceAddress)); submit.setDestAddress(new Address(destTon, destNpi, destAddress)); SubmitSmResp submitResponce = getSession().submit(submit, submitTimeout); if (submitResponce.getCommandStatus() == SmppConstants.STATUS_OK) { LOGGER.info("SMS submitted, message id: " + submitResponce.getMessageId());
@Override public void run() { SmppSession smppSession = smppClient.getSession(); if (smppSession != null && smppSession.isBound()) { try { smppSession.enquireLink(new EnquireLink(), enquireLinkTimeout); } catch (SmppTimeoutException | SmppChannelException | RecoverablePduException | UnrecoverablePduException error) { LOGGER.warn("Enquire link failed, executing reconnect: ", error); smppClient.scheduleReconnect(); } catch (InterruptedException error) { LOGGER.info("Enquire link interrupted, probably killed by reconnecting"); } } else { LOGGER.warn("Enquire link running while session is not connected"); } }
if (smppSession != null && smppSession.isBound()) { try { smppSession.enquireLink(new EnquireLink(), 10000); smppSession.close(); } catch (Exception ex) { logger.error(String.format("Failed to close smpp client session for %s.", smppSession.getConfiguration().getName())); esme.getSystemId(), (smppSession == null ? null : smppSession.getStateName()))); smppSession.close(); } catch (Exception e) { logger.error(String.format("Failed to close smpp client session for %s.", smppSession.getConfiguration().getName()));
public void sessionDestroyed(SmppSession session) { synchronized (this) { if (logger.isInfoEnabled()) { logger.info(String.format("Session destroyed: %s", session.getConfiguration().getSystemId())); } // print out final stats if (session.hasCounters()) { logger.info(String.format("final session rx-submitSM: %s", session.getCounters().getRxSubmitSM())); } // remove esmeServer out of enquire list String esmeName = session.getConfiguration().getName(); Esme esmeServer = this.esmeManagement.getEsmeByName(esmeName); esmeServer.setServerBound(false); esmeServer.resetEnquireLinkFail(); this.smppServerOpsThread.removeEnquireList(esmeName); DefaultSmppSession defaultSession = (DefaultSmppSession) session; // firing of onPduRequestTimeout() for sent messages for which we do not have responses Window<Integer, PduRequest, PduResponse> wind = defaultSession.getSendWindow(); Map<Integer, WindowFuture<Integer, PduRequest, PduResponse>> futures = wind.createSortedSnapshot(); for (WindowFuture<Integer, PduRequest, PduResponse> future : futures.values()) { this.logger.warn("Firing of onPduRequestTimeout from DefaultSmppServerHandler.sessionDestroyed(): " + future.getRequest().toString()); defaultSession.expired(future); } // make sure it's really shutdown session.destroy(); } }
@Override protected void _stop() throws Exception { if (this.smppSession != null) { if (this.smppSession.isBinding() || this.smppSession.isBound()) this.smppSession.unbind(this.timeout); this.smppSession.destroy(); } if (this.clientBootstrap != null) this.clientBootstrap.destroy(); if (this.monitorExecutor != null) this.monitorExecutor.shutdownNow(); }
public void bind() { if ( this.state == ClientState.BOUND || this.state == ClientState.IDLE ) { log.debug("Binding state"); if ( this.session != null && this.session.isBound() ) { this.session.close(); this.session.destroy(); } this.state = ClientState.BINDING; if (elinkTask != null) { this.elinkTask.cancel(true); } runRebindTask(); } }
static public void close(SmppSession session) { if (session != null) { try { session.close(); } catch (Throwable t) { logger.warn("Unable to cleanly close session: {}", t); } } }
public void doStop() { if (this.session0 != null) { this.session0.unbind(5000); this.session0.destroy(); this.session0 = null; } if (this.defaultSmppServer != null) { this.defaultSmppServer.stop(); this.defaultSmppServer.destroy(); this.defaultSmppServer = null; } if (clientBootstrap != null) { try { clientBootstrap.destroy(); executor.shutdownNow(); monitorExecutor.shutdownNow(); } catch (Exception e) { } clientBootstrap = null; executor = null; monitorExecutor = null; } enableStart(true); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); this.addMessage("Session has been stopped", ""); }
@Override protected void handleDelayedRecord(DelayedRecord delayedRecord) throws Exception { SmppSession session = delayedRecord.getUsedSession(sessionManager); PduRequest request = delayedRecord.getRequest(sessionManager.getNextSequenceNumber()); if (session != null && session.isBound()) { session.sendRequestPdu(request, sendTimoutMilis, false); } else { logger.info("Session does not exist or is not bound {}. Request not sent {}", session, request); } }
@Override public void run() { if (client.state == ClientState.BOUND) { SmppSession session = client.getSession(); log.debug("Send elink"); try { session.enquireLink(new EnquireLink(), TimeUnit.SECONDS.toMillis(10)); log.debug("Elink sent successfull"); } catch (RecoverablePduException ex) { log.debug("{}", ex); } catch (UnrecoverablePduException ex) { log.debug("{}", ex); } catch (SmppTimeoutException ex) { client.bind(); log.debug("{}", ex); } catch (SmppChannelException ex) { log.debug("{}", ex); } catch (InterruptedException ex) { log.debug("{}", ex); } } }
private void doSendBadPacket() { // TODO: .............................. SubmitSm submitSm = new SubmitSm(); try { ((TestSmppSession)this.session0).setMalformedPacket(); this.session0.submit(submitSm, 1000); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
@Override public SmppSession getUsedSession(SmppSessionManager sessionManager) { String systemId = getSession().getConfiguration().getSystemId(); return sessionManager.getNextServerSession(systemId); }
session.unbind(1000); return pduRequest.createResponse();
if (smppSession != null && smppSession.isBound()) { try { smppSession.enquireLink(new EnquireLink(), 10000); smppSession.close(); } catch (Exception ex) { logger.error(String.format("Failed to close smpp client session for %s.", smppSession.getConfiguration().getName())); esme.getSystemId(), (smppSession == null ? null : smppSession.getStateName()))); smppSession.close(); } catch (Exception e) { logger.error(String.format("Failed to close smpp client session for %s.", smppSession.getConfiguration().getName()));
logger.info(String.format("Session destroyed: %s", session.getConfiguration().getSystemId())); if (session.hasCounters()) { logger.info(String.format("final session rx-submitSM: %s", session.getCounters().getRxSubmitSM())); String esmeName = session.getConfiguration().getName(); Esme esmeServer = this.esmeManagement.getEsmeByName(esmeName); esmeServer.setServerBound(false); session.destroy();
static public void close(SmppSession session) { if (session != null) { try { session.close(); } catch (Throwable t) { logger.warn("Unable to cleanly close session: {}", t); } } }
this.smppConfig.setCountersEnabled(true); this.smppSession = this.clientBootstrap.bind(this.smppConfig, this.sessionHandler); this.enquireLinkResp = this.smppSession.enquireLink(new EnquireLink(), this.timeout); if (this.enquireLinkResp.getCommandStatus() != SmppConstants.STATUS_OK) throw new Exception("Error connection to SMPP host: " + this.enquireLinkResp.getResultMessage());