当前位置:网站首页>Wsarecv: an existing connection was forcefully closed by the remote host
Wsarecv: an existing connection was forcefully closed by the remote host
2022-06-11 10:15:00 【CSDN Q & A】
go Connection to database always disconnected remotely
func TestOpenCA(t *testing.T) { var source = "host=xx.xx.xx.xx user=xxx password=xxx dbname=xxx port=5432 sslmode=disable" //var source = "host=127.0.0.1 user=postgres password=xxx dbname=xx port=5432 sslmode=disable" db, err := sql.Open("postgres", source) if err != nil { t.Error(err) } var sql = `INSERT INTO "test" (a,b,c) VALUES("1","2","3") ,("1","2","3") ;` fmt.Println(db.Ping()) db.SetConnMaxIdleTime(10 * time.Minute) db.SetConnMaxLifetime(10 * time.Minute) var errIdx = 0 for i := 0; i < 100; i++ { _, err := db.ExecContext(context.Background(), sql) if err != nil { errIdx += 1 //t.Error(err) //return } //fmt.Println(c.LastInsertId()) } fmt.Println(errIdx) defer db.Close() fmt.Scanln()}It's the code , Local database inserts are successful , The database of the server is remotely , Always report errors wsarecv: An existing connection was forcibly closed by the remote host, The Internet should be OK ,sql Also no problem , It's just that this error is reported frequently .
边栏推荐
- Datagrip 2022, datagrip function
- Wuenda machine learning course - week 7
- MySQL 权限管理和备份
- Understanding polymorphism?
- 1. system in Library
- ESP8266_ Mqtt protocol
- MySQL comparison
- After four years of outsourcing, it was abandoned
- Q1's revenue exceeded Wall Street's expectations, and the value of Zhiwen group is waiting to return
- Picture rule page turning
猜你喜欢

对于力士乐电磁换向阀的功能与作用,你知道多少

Function and function of wandfluh proportional valve

鼠标点击坐标转换生成

UGUI

【Objective-C】‘NSAutoreleasePool‘ is unavailable: not available in automatic reference counting mode

Correct opening method of RPC | understand go native net/rpc package

Mysql-- index

Integer lifting example

Technology cloud report: privacy computing under the wave of Web3.0

How much do you know about software compatibility testing? How to select a software compatibility testing organization?
随机推荐
Initial deployment of Servlet
puppeteer入门之 BrowserFetcher 类
利用PHP开发的一款万能、表白墙系统部分代码片段
Knowledge drop - personality analysis - four types of method
Technology cloud report: privacy computing under the wave of Web3.0
Function and function of wandfluh proportional valve
【clickhouse专栏】新建库角色用户初始化
Wechat applet ordering system with source code
启动jar
Project lifecycle
Mouse click coordinate transformation generation
BeanFactoryPostProcessor 与BeanPostProcessor的区别
php 中使用exec显示报错
基于SSM+Vue+OSS的“依伴汉服”商城设计与开发(含源码+论文+ppt+数据库)
RSA signature issues
完结C语言
Use of JMeter (simulating high concurrency)
Handwritten code call, apply, bind
VK2C22A/B抗干扰系列电表,水表段码LCD液晶驱动芯片资料(可定制DICE/COG)
本人书签常存的地址