1

I use go-diameter as client trying connecting to a server. I follow the example on the repo but found out there's some error happened in connecting. Here is my sample code:

cfg := &sm.Settings{
    OriginHost:       datatype.DiameterIdentity(originHost),
    OriginRealm:      datatype.DiameterIdentity(originRealm),
    VendorID:         diameterVendorID,
    ProductName:      productName,
    FirmwareRevision: firmwareRevision,
    HostIPAddresses:  []datatype.Address{
        datatype.Address(net.ParseIP(viper.GetString("my.ip"))),
    },
}

// Create the state machine (it's a diam.ServeMux) and client.
mux := sm.New(cfg)
// CER -> for sending
cli := &sm.Client{
    Dict:               dict.Default,
    Handler:            mux,
    MaxRetransmits:     3,
    RetransmitInterval: time.Second,
    EnableWatchdog:     true,
    WatchdogInterval:   5 * time.Second,

    AuthApplicationID: []*diam.AVP{
        // Advertise support for credit control application
        diam.NewAVP(avp.AuthApplicationID, avp.Mbit, 0, datatype.Unsigned32(diameterAuthAppID)), // RFC 4006
    },
}

mux.Handle(diam.CCA, handleCCA())
mux.Handle(diam.DPA, handleDPA())

// Print error reports.
go printErrors(ctx, mux.ErrorReports())

println("diameter connect....")
connect := func() (diam.Conn, error) {
    
    /*I test these two ways, both return same error*/
    return cli.DialTimeout(addr, 5*time.Second)
    //return dial(cli, addr, "", "","tcp", false)
}
c, err := connect()
if err != nil {
    println(err)
}

The code is just like the sample client code on go-diameter repo, but I will got errors as:

diameter connect....    
diameter error on x.x.x.x:3868: read tcp x.x.x.x:60766-\u003ex.x.x.x:3868: use of closed network connection

Appreciate if there's any suggestions. Thanks.

1
  • Probably first step to troubleshoot is to capture using tcpdump or Wireshark and see what's happening. This smells like connection you're trying to use dies. Commented Nov 21, 2020 at 20:15

1 Answer 1

1

Answered by my self. I found the error is happened at network timeout. After I extend the timeout, the connection is OK.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.