英文:
Golang send http request sending twice instead of once
问题
我正在尝试使用以下代码进行简单的HTTP POST请求:
它发送了两次HTTP请求(我尝试过发送到自己的Web服务和Firebase消息服务器)。有人知道问题出在哪里吗?谢谢。
编辑
不用理我了,我发现是AVG杀毒软件引起的问题。如果我运行go run program.go
然后只按一次回车,AVG会中断并表示已经扫描过了,然后让它继续运行。这导致HTTP请求发送了两次。如果在运行之前禁用杀毒软件,那么另一端只会接收到一次HTTP请求。我已经多次开启和关闭杀毒软件来确认这是问题的原因。
英文:
I am trying to do simple http post request using the following code:
Golang code from another SO post
It's sending the http request twice (I tried both to my own web service and also to the Firebase messaging server). Anyone have any idea of what's wrong? Thank you.
Edit
Ignore me, figured out it's the AVG anti virus causing the problem. If I do:go run program.go
then hit enter just once, AVG interrupts saying it has scan it and then let it run. This results in the http call twice. If I disable antivirus before running, then the http requrest is received only once on the other side. I've switched the antivirus on and off a few times to confirm this is the cause.
答案1
得分: 1
根据我的编辑,问题的原因是 AVG 杀毒软件。控制台日志中没有任何指示程序的任何部分运行了两次。不确定为什么会有负评,我花了几个小时的时间,从 Firebase 消息服务器迁移到自己的 Web 服务器以消除外部依赖,并且甚至阅读了 net/http 包中的源代码。
英文:
As in my edit, the cause was AVG anti virus. There was nothing in the console log indicating any part of the program was run twice. Not sure why the downvotes, I spend a few hours on this, move from Firebase messaging server to my own webserver to remove external dependency, and even read the source in net/http package.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论