Is this a Go bug? Two requests coming in from IPv4 and IPv6.

blov · · 412 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I am building a web app that lets users post a file via a form and have it update a database. I am finding that sometimes there are duplicate entries in the database. Each duplicate has a similar pattern, one entry has an IPv4 IP address logged, and a few seconds later is an identical entry with an IPv6 IP address logged.</p> <p>Is there any circumstance you can think of where this would be normal?</p> <hr/>**评论:**<br/><br/>abhayakara: <pre><p>Sounds like the browser is doing happy eyeballs: trying on both IPv4 and IPv6 at the same time. Why it&#39;s completing both requests is an interesting question, however—that sounds like a bug.</p></pre>NikkoTheGreeko: <pre><p>So it looks like I may have solved it. I hope this helps someone in the future.</p> <p>I had a file upload. However, before the file was fully saved and moved, I was adding a new record to the database. If the internet connection was slow, the file upload was timing out so I had a record with no file, and when trying again I got a record with a file (if successfully uploaded). Now why it went to IPv4 on the second try, I have no idea.</p> <p>Which now leads me to another question. Is there a built-in way to allow the timeout for a file upload to be longer than the general read/write timeouts?</p></pre>abhayakara: <pre><p>It went IPv4 the second time because of the timeout. The timeout is probably a network issue, not a &#34;it took too long to do the upload&#34; issue, so I don&#39;t think there&#39;s a way to control that.</p></pre>NikkoTheGreeko: <pre><p>It was a network issue. File upload is via cell phone and my signal was poor at the time.</p> <p>I added a timeout message to the user and duplicate records are handled properly.</p></pre>allhatenocattle: <pre><p>One thing to check is if you have a default handler (handling every request path), then you are likely getting the user&#39;s intended request and also a request for favicon from the browser. If that is the case, you can make your handler explicit for the path you want. if you want to debug further, you could log the request path.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

412 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传