AberrantSMPP icon indicating copy to clipboard operation
AberrantSMPP copied to clipboard

CallBackNum issue

Open UncleTedd opened this issue 1 year ago • 15 comments

Tried to create a SmppSubmitSm and set all the needed values to it, i didnt need callbacknum but it kept giving me this error: "ERROR - Send error: callback_num size must be between 4 and 19 characters." so i tried to add it, used different encodings to get the bytes of that string but the issue didnt go away. Tried to fill other callbacknum fields but still the issue didnt go away. Any suggestions on what to do?

UncleTedd avatar Oct 17 '24 04:10 UncleTedd

var submitSm = new SmppSubmitSm { CommandStatus = CommandStatus.ESME_ROK, SourceAddressTon = Pdu.TonType.Alphanumeric, SourceAddressNpi = Pdu.NpiType.Unknown, SourceAddress = from, DataCoding = DataCoding.UCS2, PriorityFlag = Pdu.PriorityType.Lowest, ShortMessage = message, DestinationAddressTon = Pdu.TonType.International, DestinationAddressNpi = Pdu.NpiType.ISDN, DestinationAddress = to, CallbackNum = callbackNumBytes, CallbackNumPresInd = 0x01, CallbackNumAtag = callbackNumAtag };

UncleTedd avatar Oct 17 '24 04:10 UncleTedd

Hi,

What are you passing as 'callbackNumBytes'..

Regards Pablo

On Thu, Oct 17, 2024 at 6:48 AM Osimjon Gulakov @.***> wrote:

var submitSm = new SmppSubmitSm { CommandStatus = CommandStatus.ESME_ROK, SourceAddressTon = Pdu.TonType.Alphanumeric, SourceAddressNpi = Pdu.NpiType.Unknown, SourceAddress = from, DataCoding = DataCoding.UCS2, PriorityFlag = Pdu.PriorityType.Lowest, ShortMessage = message, DestinationAddressTon = Pdu.TonType.International, DestinationAddressNpi = Pdu.NpiType.ISDN, DestinationAddress = to, CallbackNum = callbackNumBytes, CallbackNumPresInd = 0x01, CallbackNumAtag = callbackNumAtag };

— Reply to this email directly, view it on GitHub https://github.com/pruiz/AberrantSMPP/issues/30#issuecomment-2418491069, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABOV6LD3MYKT3OQKXMDVRLZ346TDAVCNFSM6AAAAABQC3QAWGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJYGQ4TCMBWHE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

pruiz avatar Oct 17 '24 09:10 pruiz

Hi. i was passing 12345 as an example. I passes null and the issue is gone now. Now i am facing a different issue. Client has a Start() method and this method has autoconnection handler or so, when i call Start(), i get this,Client isStarted is : True. Then i call Connect() and it throws something like you cant explicitly call connect when the autoconnection handler is on. But the state of the connection is : INFO - Client state is : Inactive When i try to call Bind(), it throws this : Connection error: Can't bind non-connected client, call ConnectAsync() first.

UncleTedd avatar Oct 17 '24 10:10 UncleTedd

Start is meant to try to connect automatically (and retry periodically if failed or connection dropped). However, if manual connection handling is intended, the Connect method can be used instead. But using both at the same time is not allowed.

On Thu, Oct 17, 2024 at 12:04 PM Osimjon Gulakov @.***> wrote:

Hi. i was passing 12345 as an example. I passes null and the issue is gone now. Now i am facing a different issue. Client has a Start() method and this method has autoconnection handler or so, when i call Start(), i get this,Client isStarted is : True. Then i call Connect() and it throws something like you cant explicitly call connect when the autoconnection handler is on. But the state of the connection is : INFO - Client state is : Inactive When i try to call Bind(), it throws this : Connection error: Can't bind non-connected client, call ConnectAsync() first.

— Reply to this email directly, view it on GitHub https://github.com/pruiz/AberrantSMPP/issues/30#issuecomment-2419102772, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABOV6NE2IEO5GZEI7NIL6DZ36DSVAVCNFSM6AAAAABQC3QAWGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJZGEYDENZXGI . You are receiving this because you commented.Message ID: @.***>

pruiz avatar Oct 17 '24 10:10 pruiz

Appreciate your help Pablo. I used start(), and i get this error : NFO - Client isStarted is : False 2024-10-17 10:54:48,908 INFO - Client state is : Inactive 2024-10-17 10:54:48,909 ERROR - Connection error: Can't bind non-connected client, call ConnectAsync() first. 2024-10-17 10:54:48,914 ERROR - Detailed Exception: System.InvalidOperationException: Can't bind non-connected client, call ConnectAsync() first. at AberrantSMPP.Utility.GuardEx.Against(Boolean invalid, String message, String caller) at AberrantSMPP.SMPPClient.Bind(). I used Inetlab and it worked just fine. i wonder what could the issue be?

UncleTedd avatar Oct 17 '24 11:10 UncleTedd

"Client state is: Inactive" means the SMPPClient is not able to connect to the smpp server. Please review connection details (like host/ip, port, credentials, etc.)

Also, you can hook up connection callback delegates to get information about connecting errors..

On Thu, Oct 17, 2024 at 1:08 PM Osimjon Gulakov @.***> wrote:

Appreciate your help Pablo. I used start(), and i get this error : NFO - Client isStarted is : False 2024-10-17 10:54:48,908 INFO - Client state is : Inactive 2024-10-17 10:54:48,909 ERROR - Connection error: Can't bind non-connected client, call ConnectAsync() first. 2024-10-17 10:54:48,914 ERROR - Detailed Exception: System.InvalidOperationException: Can't bind non-connected client, call ConnectAsync() first. at AberrantSMPP.Utility.GuardEx.Against(Boolean invalid, String message, String caller) at AberrantSMPP.SMPPClient.Bind(). I used Inetlab and it worked just fine. i wonder what could the issue be?

— Reply to this email directly, view it on GitHub https://github.com/pruiz/AberrantSMPP/issues/30#issuecomment-2419228305, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABOV6KEUL3AUBVXGJ6GMOLZ36LBBAVCNFSM6AAAAABQC3QAWGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJZGIZDQMZQGU . You are receiving this because you commented.Message ID: @.***>

pruiz avatar Oct 17 '24 11:10 pruiz

I am sorry if i am being anooying, but would you please take a look at how i create the client? Because i am getting the same error. _client = new SMPPClient(host, port) { SystemId = _systemId, Password = _password, NpiType = Pdu.NpiType.Unknown, TonType = Pdu.TonType.Alphanumeric, }; Error i am getting is : Client state changed to: Connecting 2024-10-17 11:43:14,366 INFO - Client state changed to: Inactive 2024-10-17 11:43:14,367 ERROR - Connection error: System.AggregateException: One or more errors occurred. (Name or service not known) ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (00000005, 0xFFFDFFFF): Name or service not known at System.Net.Dns.GetHostEntryOrAddressesCore(IPAddress address, Boolean justAddresses, AddressFamily addressFamily, ValueStopwatch stopwatch) at System.Net.Dns.<>c.<GetHostEntryOrAddressesCoreAsync>b__33_1(Object s, ValueStopwatch stopwatch) at System.Net.Dns.<>c__DisplayClass39_01.<RunAsync>b__0(Task <p0>, Object <p1>) at System.Threading.Tasks.ContinuationResultTaskFromTask1.InnerInvoke() at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location --- at DotNetty.Transport.Bootstrapping.DefaultNameResolver.ResolveAsync(EndPoint address) at DotNetty.Transport.Bootstrapping.Bootstrap.DoResolveAndConnectAsync(EndPoint remoteAddress, EndPoint localAddress) at DotNetty.Transport.Bootstrapping.Bootstrap.DoResolveAndConnectAsync(EndPoint remoteAddress, EndPoint localAddress)

UncleTedd avatar Oct 17 '24 11:10 UncleTedd

From the 'Name or service not known' looks like the hostname specified as 'host' on SMPPClient's ctor is not a valid hostname (ie. cannot be resolved by dns).

On Thu, Oct 17, 2024 at 1:47 PM Osimjon Gulakov @.***> wrote:

I am sorry if i am being anooying, but would you please take a look at how i create the client? Because i am getting the same error. _client = new SMPPClient(host, port) { SystemId = _systemId, Password = _password, NpiType = Pdu.NpiType.Unknown, TonType = Pdu.TonType.Alphanumeric, }; Error i am getting is : Client state changed to: Connecting 2024-10-17 11:43:14,366 INFO - Client state changed to: Inactive 2024-10-17 11:43:14,367 ERROR - Connection error: System.AggregateException: One or more errors occurred. (Name or service not known) ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (00000005, 0xFFFDFFFF): Name or service not known at System.Net.Dns.GetHostEntryOrAddressesCore(IPAddress address, Boolean justAddresses, AddressFamily addressFamily, ValueStopwatch stopwatch) at System.Net.Dns.<>c.b__33_1(Object s, ValueStopwatch stopwatch) at System.Net.Dns.<>c__DisplayClass39_01.<RunAsync>b__0(Task , Object ) at System.Threading.Tasks.ContinuationResultTaskFromTask 1.InnerInvoke() at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location --- at DotNetty.Transport.Bootstrapping.DefaultNameResolver.ResolveAsync(EndPoint address) at DotNetty.Transport.Bootstrapping.Bootstrap.DoResolveAndConnectAsync(EndPoint remoteAddress, EndPoint localAddress) at DotNetty.Transport.Bootstrapping.Bootstrap.DoResolveAndConnectAsync(EndPoint remoteAddress, EndPoint localAddress)

— Reply to this email directly, view it on GitHub https://github.com/pruiz/AberrantSMPP/issues/30#issuecomment-2419306541, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABOV6KPTBS5QCQFYXUL52DZ36PVDAVCNFSM6AAAAABQC3QAWGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJZGMYDMNJUGE . You are receiving this because you commented.Message ID: @.***>

pruiz avatar Oct 17 '24 11:10 pruiz

I get this, but when i try to use Inetlabs smpp and pass the same IP and Ports it connects with no problem. What could the problem be?

UncleTedd avatar Oct 17 '24 11:10 UncleTedd

Not sure.. what are you actually passing as 'host'?

On Thu, Oct 17, 2024 at 1:59 PM Osimjon Gulakov @.***> wrote:

I get this, but when i try to use Inetlabs smpp and pass the same IP and Ports it connects with no problem. What could the problem be?

— Reply to this email directly, view it on GitHub https://github.com/pruiz/AberrantSMPP/issues/30#issuecomment-2419335347, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABOV6MBSQ4VHNVNS26EYFTZ36RDPAVCNFSM6AAAAABQC3QAWGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJZGMZTKMZUG4 . You are receiving this because you commented.Message ID: @.***>

pruiz avatar Oct 17 '24 12:10 pruiz

as host i am passing the ip of the smsc server

UncleTedd avatar Oct 17 '24 12:10 UncleTedd

i am able to connect to the server using telnet

UncleTedd avatar Oct 17 '24 12:10 UncleTedd

may you share a full excerpt of the failing code?

pruiz avatar Oct 17 '24 12:10 pruiz

Sure!

private Task ConnectAsyncOld() { try { if (_isConnected) return Task.FromResult(true);

        _log.Info($"Attempting to connect to SMSC: {_client.Host}:{_client.Port}");
        _log.Info($"Client isStarted is : {_client.Started}");
        _client.Start();
        _log.Info($"Client state is : {_client.State}");
        _isConnected = true;
        _log.Info($"Client state is : {_client.State}");
        return Task.FromResult(true);
    }
    catch (Exception ex)
    {
        _log.Error($"Connection error: {ex.Message}");
        _log.Error($"Detailed Exception: {ex.StackTrace}");
        _isConnected = false;
        return Task.FromResult(false);
    }
}

public async Task<bool> SendSmsAsync(string to, string from, string message)
{
    try
    {
        var started = await ConnectAsyncOld();
        if (started)  _log.Info($"Client State is {_client.State}"); 
        
        var submitSm = new SmppSubmitSm
        {
            CommandStatus = CommandStatus.ESME_ROK,
            SourceAddressTon = Pdu.TonType.Alphanumeric,
            SourceAddressNpi = Pdu.NpiType.Unknown,
            SourceAddress = from,
            DataCoding = DataCoding.UCS2,
            PriorityFlag = Pdu.PriorityType.Lowest,
            ShortMessage = message,
            DestinationAddressTon = Pdu.TonType.International,
            DestinationAddressNpi = Pdu.NpiType.ISDN,
            DestinationAddress = to.Replace("+", ""),
            CallbackNum = null
        };

        _log.Info($"Sending SMS: {JsonConvert.SerializeObject(submitSm)}");

        var response = _client.SendPdu(submitSm);
        _log.Info($"Response from send SMS is: {response}");

        if (response > 0)
        {
            _log.Info("Message sent successfully.");
            return true;
        }

        _log.Error("Failed to send message. Status: " + response);
        return false;
    }
    catch (Exception ex)
    {
        _log.Error($"Send error: {ex.Message}");
        return false;
    }
}

UncleTedd avatar Oct 17 '24 12:10 UncleTedd

Hi Pablo. Any suggestions on how to connect properly?

UncleTedd avatar Oct 18 '24 07:10 UncleTedd