gpt4 book ai didi

go - 如何解决直径连接错误:使用封闭的网络连接?

转载 作者:行者123 更新时间:2023-12-01 22:21:54 25 4
gpt4 key购买 nike

我将go-diameter用作尝试连接服务器的客户端。我按照仓库中的示例进行操作,但是发现在连接中发生了一些错误。这是我的示例代码:

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)
}
该代码就像go-diameter repo上的示例客户端代码一样,但是我会得到如下错误:
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
谢谢您有什么建议。谢谢。

最佳答案

由我自己回答。我发现错误发生在网络超时。延长超时后,连接正常。

关于go - 如何解决直径连接错误:使用封闭的网络连接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62946432/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com