# 把`[::1]`改成`127.0.0.1`之后
~/code/ruby ❯ /home/bczhc/code/ruby/demo2
Fetching http://127.0.0.1:3000/playlist/detail?id=2666362457
{"code":200,"relatedVideos":{},"playlist":{"id":2666362457,"name":"我喜欢的音乐","coverImgId":3
Fetching http://127.0.0.1:3000/playlist/detail?id=2666362458
{"code":200,"relatedVideos":{},"playlist":{"id":2666362458,"name":"橙光","coverImgId":7146825581822
Fetching http://127.0.0.1:3000/playlist/detail?id=2666362459
{"code":200,"relatedVideos":{},"playlist":{"id":2666362459,"name":"我喜欢的音乐","coverImgId":1
Fetching http://127.0.0.1:3000/playlist/detail?id=2666362460
{"code":200,"relatedVideos":{},"playlist":{"id":2666362460,"name":"nc","coverImgId":10995116547412140
Fetching http://127.0.0.1:3000/playlist/detail?id=2666362461
{"code":200,"relatedVideos":{},"playlist":{"id":2666362461,"name":"日文","coverImgId":1099511638520
Fetching http://127.0.0.1:3000/playlist/detail?id=2666362462
{"code":200,"relatedVideos":{},"playlist":{"id":2666362462,"name":"我喜欢的音乐","coverImgId":3
Fetching http://127.0.0.1:3000/playlist/detail?id=2666362463
{"code":200,"relatedVideos":{},"playlist":{"id":2666362463,"name":"填煙花美但只是瞬間玻喜�
Fetching http://127.0.0.1:3000/playlist/detail?id=2666362464
{"code":200,"relatedVideos":{},"playlist":{"id":2666362464,"name":"我喜欢的音乐","coverImgId":3
环境
系统/平台: Archlinux rolling; kernel 6.7.0-rc7-modified-g861deac3b092-dirty
nodejs 版本: v21.4.0
API版本: 4.14.0
出现问题
当使用IPv6的回环地址请求时,返回406:
{"msg":"操作频繁,请稍候再试","code":406,"message":"操作频繁,请稍候再试"}重现步骤
请求代码
或
期待效果
正常请求
更多注明
当把url中的
[::1]改成127.0.0.1后,就不报操作频繁的错了,而以IPv6回环地址请求时就会,正常的话不应该出现这样的差别。最开始这个问题,是我用的
http://localhost:3000地址,然后发现用Ruby请求就老报这个错,很奇怪。我并没频繁请求,已经等了很久了再请求还是那样。后来又发现在浏览器里和IntelliJ的HTTP Client里请求都是正常的,唯独Ruby出错。我又在Kotlin实现了同样的逻辑,Kotlin也是好的。在Wireshark中比较Ruby和Kotlin的请求,发现Ruby对localhost使用IPv6回环地址,而Kotlin的ktor还是IPV4,遂发现这个问题。