Search in sources :

Example 21 with SmppChannelException

use of com.cloudhopper.smpp.type.SmppChannelException in project load-balancer by RestComm.

the class CommonTest method initialization.

@BeforeClass
public static void initialization() {
    boolean enableSslLbPort = false;
    boolean terminateTLSTraffic = true;
    // start lb
    balancer = new BalancerRunner();
    ConfigInit.getLbProperties(enableSslLbPort, terminateTLSTraffic).getSmppConfiguration().setTimeoutConnection(2000);
    ConfigInit.getLbProperties(enableSslLbPort, terminateTLSTraffic).getSmppConfiguration().setTimeoutConnectionCheckClientSide(5000);
    ConfigInit.getLbProperties(enableSslLbPort, terminateTLSTraffic).getSmppConfiguration().setTimeoutConnectionCheckServerSide(5000);
    balancer.start(ConfigInit.getLbProperties(enableSslLbPort, terminateTLSTraffic));
    // start servers
    serverArray = new DefaultSmppServer[serverNumbers];
    serverHandlerArray = new DefaultSmppServerHandler[serverNumbers];
    for (int i = 0; i < serverNumbers; i++) {
        serverHandlerArray[i] = new DefaultSmppServerHandler();
        serverArray[i] = new DefaultSmppServer(ConfigInit.getSmppServerConfiguration(i, false), serverHandlerArray[i], executor, monitorExecutor);
        logger.info("Starting SMPP server...");
        try {
            serverArray[i].start();
        } catch (SmppChannelException e) {
            logger.info("SMPP server does not started");
            e.printStackTrace();
        }
        logger.info("SMPP server started");
    }
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : DefaultSmppServer(com.cloudhopper.smpp.impl.DefaultSmppServer) BalancerRunner(org.mobicents.tools.sip.balancer.BalancerRunner) SmppChannelException(com.cloudhopper.smpp.type.SmppChannelException) BeforeClass(org.junit.BeforeClass)

Example 22 with SmppChannelException

use of com.cloudhopper.smpp.type.SmppChannelException in project traccar by tananaev.

the class SmppClient method sendMessageSync.

public synchronized void sendMessageSync(String destAddress, String message, boolean command) throws RecoverablePduException, UnrecoverablePduException, SmppTimeoutException, SmppChannelException, InterruptedException, IllegalStateException {
    if (getSession() != null && getSession().isBound()) {
        SubmitSm submit = new SubmitSm();
        byte[] textBytes;
        textBytes = CharsetUtil.encode(message, command ? commandsCharsetName : notificationsCharsetName);
        submit.setDataCoding(command ? commandsDataCoding : notificationsDataCoding);
        if (requestDlr) {
            submit.setRegisteredDelivery(SmppConstants.REGISTERED_DELIVERY_SMSC_RECEIPT_REQUESTED);
        }
        if (textBytes != null && textBytes.length > 255) {
            submit.addOptionalParameter(new Tlv(SmppConstants.TAG_MESSAGE_PAYLOAD, textBytes, "message_payload"));
        } else {
            submit.setShortMessage(textBytes);
        }
        submit.setSourceAddress(command ? new Address(commandSourceTon, commandSourceNpi, commandSourceAddress) : new Address(sourceTon, sourceNpi, sourceAddress));
        submit.setDestAddress(new Address(destTon, destNpi, destAddress));
        SubmitSmResp submitResponce = getSession().submit(submit, submitTimeout);
        if (submitResponce.getCommandStatus() == SmppConstants.STATUS_OK) {
            Log.debug("SMS submitted, message id: " + submitResponce.getMessageId());
        } else {
            throw new IllegalStateException(submitResponce.getResultMessage());
        }
    } else {
        throw new SmppChannelException("SMPP session is not connected");
    }
}
Also used : Address(com.cloudhopper.smpp.type.Address) SubmitSmResp(com.cloudhopper.smpp.pdu.SubmitSmResp) SubmitSm(com.cloudhopper.smpp.pdu.SubmitSm) SmppChannelException(com.cloudhopper.smpp.type.SmppChannelException) Tlv(com.cloudhopper.smpp.tlv.Tlv)

Aggregations

SmppChannelException (com.cloudhopper.smpp.type.SmppChannelException)22 BeforeClass (org.junit.BeforeClass)21 BalancerRunner (org.mobicents.tools.sip.balancer.BalancerRunner)21 DefaultSmppServer (com.cloudhopper.smpp.impl.DefaultSmppServer)19 LoadBalancerConfiguration (org.mobicents.tools.configuration.LoadBalancerConfiguration)3 SubmitSm (com.cloudhopper.smpp.pdu.SubmitSm)1 SubmitSmResp (com.cloudhopper.smpp.pdu.SubmitSmResp)1 Tlv (com.cloudhopper.smpp.tlv.Tlv)1 Address (com.cloudhopper.smpp.type.Address)1 UrlRewriteTest (org.mobicents.tools.http.balancer.UrlRewriteTest)1