failed to connect error replacement

This commit is contained in:
kemvl 2024-03-29 11:23:51 +05:00
parent 6f8896d0ab
commit c74d5584b0
1 changed files with 5 additions and 11 deletions

View File

@ -15,8 +15,6 @@ type SMPPClient struct {
func NewSMPPClient(cfg *config.Config) (*SMPPClient, error) {
smppCfg := cfg.SMPP
log.Println("SMPP Config:", smppCfg) // This will print the SMPP configuration
tx := &smpp.Transceiver{
Addr: smppCfg.Addr,
User: smppCfg.User,
@ -24,16 +22,12 @@ func NewSMPPClient(cfg *config.Config) (*SMPPClient, error) {
Handler: func(p pdu.Body) {},
}
log.Println("Attempting to bind to SMPP server at address:", smppCfg.Addr)
connStatus := tx.Bind()
go func() {
for c := range connStatus {
if c.Status() != smpp.Connected {
log.Println("Failed to connect:", c.Error())
}
}
}()
status := <-connStatus
if status.Status() != smpp.Connected {
log.Println("Failed to connect:", status.Error())
return nil, status.Error()
}
return &SMPPClient{Transceiver: tx}, nil
}