twitter-archive / cloudhopper-smpp

Efficient, scalable, and flexible Java implementation of the Short Messaging Peer to Peer Protocol (SMPP)
Other
382 stars 356 forks source link

Send message to a connected client #128

Closed blackchineykh closed 7 years ago

blackchineykh commented 7 years ago

Hi im new to this and was able to successfully bind in transceiver mode and send messages from client to the smpp server towards a simulated SMSC. However, I am trying to send a message back to a connected client. I have a single client connected and store the session for use later when I receive a request to send a message to this client from smsc. However it does not work. It doesnt reach the client side.

The below is my code:

`SmppServerSession smppSession = smppSessions.get(deviceId);

        DeliverSm pdu = new DeliverSm();

        pdu.setSourceAddress(new Address((byte)0x03, (byte)0x00, packet.getMessage().getRecipientAddress()));
        pdu.setDestAddress(new Address((byte)0x01, (byte)0x01, packet.getMessage().getDestinationAddress()));
        byte[] textBytes = CharsetUtil.encode(packet.getMessage().getText(), CharsetUtil.CHARSET_GSM);
        pdu.setShortMessage(textBytes);

         WindowFuture<Integer,PduRequest,PduResponse> future = smppSession.sendRequestPdu(pdu, 10000, false);
            if (!future.await()) {
                log.error("Failed to receive deliver_sm_resp within specified time");
            } else if (future.isSuccess()) {
                DeliverSmResp deliverSmResp = (DeliverSmResp)future.getResponse();
                log.info("deliver_sm_resp: commandStatus [" + deliverSmResp.getCommandStatus() + "=" + deliverSmResp.getResultMessage() + "]");
            } else {
                log.error("Failed to properly receive deliver_sm_resp: " + future.getCause());
            }`

Logs are below on smpp server side but the message isnt delivered to the connected smpp client.

_2016-11-20 22:16:37,836 INFO SmsProtocolHandler:59 - - - Received command MESSASGE_RECEIVE_REQ from client 18888707478 2016-11-20 22:16:37,837 INFO DefaultSmppSession:525 - - - async send PDU: (deliver_sm: 0x00000055 0x00000005 0x00000000 0x00000013) (body: (serviceType [] sourceAddr [0x03 0x00 [18764707478]] destAddr [0x01 0x01 [18888707478]] esmCls [0x00] regDlvry [0x00] dcs [0x00] message [5468616E6B7320666F7220616C6C6F77696E67206D6520746F206A6F696E])) (opts: ) 2016-11-20 22:16:37,844 TRACE DefaultSmppSession:628 - - - Found a future in the window for seqNum [19] 2016-11-20 22:16:37,845 TRACE DefaultSmppSession:635 - - - Caller waiting for request: (deliver_sm: 0x00000055 0x00000005 0x00000000 0x00000013) (body: (serviceType [] sourceAddr [0x03 0x00 [18888707478]] destAddr [0x01 0x01 [18888707478]] esmCls [0x00] regDlvry [0x00] dcs [0x00] message [5468616E6B7320666F7220616C6C6F77696E67206D6520746F206A6F696E])) (opts: ) 2016-11-20 22:16:37,845 INFO MessageClientManager:151 - - - deliver_smresp: commandStatus [0=OK]

I appreciate any help you can give.

Thanks

blackchineykh commented 7 years ago

I realized that the issue was due to my smpp client's bind source address not matching. It is working now.