Sending BIND on receipt of an OUTBIND

Post Reply
jim87
Posts: 3
Joined: Wed Mar 23, 2022 9:58 am

Sending BIND on receipt of an OUTBIND

Post by jim87 » Wed Mar 23, 2022 2:02 pm

I have implemented the evClientOutBind event for an SMPP server.

This event is triggered when the client connects and sends and OUTBIND message, but I am now trying to find out how the SmppServerClient can respond to that with a BIND message. I can't see how to send that BIND message down the same connection.

How can I do this ?

Thanks
jim87
Posts: 3
Joined: Wed Mar 23, 2022 9:58 am

Re: Sending BIND on receipt of an OUTBIND

Post by jim87 » Mon Apr 11, 2022 2:56 pm

Hi

Just to add some more information, to see if anyone know how to do it.
I have code similar to this, and want to receive delivered messages

Code: Select all

public class SMPPServerEndpoint
{
	public SMPPServerEndpoint( string ipAddress, unsigned short port)
	{            
		serverInstance = new SmppServer(new IPEndPoint(ipAddress,port));

		serverInstance.evClientOutBind += server_evClientOutbind;
		serverInstance.evClientDeliverSm += client_evClientDeliverSm; 		// This event doesn't exist
	}

	private void client_evClientDeliverSm(object sender, SmppServerClient client, DeliverSm data)
	{
		// process incoming Deliver 
	}

	// This event does fire when an Outbind is receieved by the server
	private void server_evClientOutbind(object sender, SmppServerClient client, OutBind data)
	{
		// SmppServerClient does not contain a BindAsync
		await client.BindAsync( ... ); 
	
		// Could be this instead of the one in the SMPPSeverEndpoint constructor, but this does not exist
		client.evClientDeliverSm += client_evClientDeliverSm; 
	}
}


Perhaps I am missing something ?
I think I should have something more like SmppClient than SmppServerClient passed into server_evClientOutbind ?

Thanks
Jim
alt
Site Admin
Posts: 985
Joined: Tue Apr 25, 2006 9:45 am

Re: Sending BIND on receipt of an OUTBIND

Post by alt » Thu May 19, 2022 9:28 pm

The outbind was incomplete in the Inetlab.SMPP library.

The version 2.9.18 has additional classes for this feature:

- SmppOutbindClient class that can establish SMPP session with ESME using Outbind command.
- SmppOutbindServerClient class, that passed down to the evClientOutBind event in the SmppServer class.
SmppOutbindServerClient has evDeliverSm event that can be used to receive outstanding messages from SMSC.

For the usage example I post here the test for the feature:

Code: Select all


                using (SmppServer server = new SmppServer(new IPEndPoint(IPAddress.Any, port)))
                {
                    void OnDeliverSm(object sender, DeliverSm data)
                    {
                        //receive DeliverSM from SMSC
                    }

                    async void OnOutBind(object sender, SmppOutbindServerClient client, OutBind data)
                    {
                        //Outbind command is received from SMSC.
                        client.evDeliverSm += OnDeliverSm;

                        //Response with Bind command
                        var resp = await client.BindAsync("test", "test");
                    }

                    //subscribe to Outbind command
                    server.evClientOutBind += OnOutBind;

                    await server.StartAsync();

                    async void OnBind(object sender, Bind data)
                    {
                        //Receive Bind command from ESME
                        var client = (SmppOutbindClient)sender;

                        var resp = data.Response;
                        data.Response = null; //prevent sending BindResp after OnBind method

                        //send response to Bind command 
                        await client.SendResponseAsync(resp);

                        // Send outstanding messages for delivery to the ESME
                        var deliverResp =
                            await client.DeliverAsync(SMS.ForDeliver().From("111").To("222").Text("test"));
                    }

                    using (SmppOutbindClient client = new SmppOutbindClient())
                    {
                        //subscribe to Bind command
                        client.evBind += OnBind;

                        if (await client.ConnectAsync(new SmppClientConnectionOptions { RemoteEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), port) }))
                        {
                            await client.OutbindAsync(new OutBind { SystemId = "MySystem", Password = "****" });
                        }

                        // waiting until all DeliverSm are received.
                        await Task.Delay(5000);

                        await client.DisconnectAsync();
                    }

jim87
Posts: 3
Joined: Wed Mar 23, 2022 9:58 am

Re: Sending BIND on receipt of an OUTBIND

Post by jim87 » Fri May 27, 2022 10:02 am

Thanks !
I have this working for my scenario, using SmppOutbindServerClient
Post Reply