/socket.io/* 404 未找到烧瓶

Posted

技术标签:

【中文标题】/socket.io/* 404 未找到烧瓶【英文标题】:/socket.io/* 404 not found flask 【发布时间】:2015-01-22 16:56:02 【问题描述】:

我正在尝试让 socketio 正常工作。当我使用以下 javascript 加载我的页面时。它尝试按预期拉取 socket.io 页面,但每次都找不到 404。

<div id="result"></div>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script src="https://cdn.socket.io/socket.io-1.2.1.js"></script>
<script>
$(function()
    var socket = io.connect('/endpoint');

    // on receive append data.sound and linebreak to result id on page
    socket.on('receive', function(data)
        $('#result').append(data.mytext);
    );

    $('form#emit').submit(function(event) 
        socket.emit('submit', account: $('#account').val(),
...

这里是 socketIO 使用的烧瓶端点

@app.route('/socket.io/<path:remaining>')
def iocg(remaining):
    from websocketinstructions import WebSocketInstructions
    socketio_manage(request.environ, '/endpoint': WebSocketInstructions, request)
    return 'done'


127.0.0.1 - - [2014-11-24 15:29:05] "GET /socket.io/?EIO=3&transport=polling&t=1416864545405-114 HTTP/1.1" 404 342 0.002768
127.0.0.1 - - [2014-11-24 15:29:06] "GET /socket.io/?EIO=3&transport=polling&t=1416864546666-4 HTTP/1.1" 404 342 0.002745
127.0.0.1 - - [2014-11-24 15:29:10] "GET /socket.io/?EIO=3&transport=polling&t=1416864550413-115 HTTP/1.1" 404 342 0.003090
127.0.0.1 - - [2014-11-24 15:29:11] "GET /socket.io/?EIO=3&transport=polling&t=1416864551672-5 HTTP/1.1" 404 342 0.003325
127.0.0.1 - - [2014-11-24 15:29:15] "GET /socket.io/?EIO=3&transport=polling&t=1416864555419-116 HTTP/1.1" 404 342 0.003315
127.0.0.1 - - [2014-11-24 15:29:16] "GET /socket.io/?EIO=3&transport=polling&t=1416864556678-6 HTT P/1.1" 404 342 0.002707
127.0.0.1 - - [2014-11-24 15:29:20] "GET /socket.io/?EIO=3&transport=polling&t=1416864560425-117 HTTP/1.1" 404 342 0.002710
127.0.0.1 - - [2014-11-24 15:29:21] "GET /socket.io/?EIO=3&transport=polling&t=1416864561684-7 HTTP/1.1" 404 342 0.003227

【问题讨论】:

【参考方案1】:

首先,检查 CDN 的链接是否有效。如果不起作用,请将其更改为 here 的新链接,例如:

https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.3.5/socket.io.min.js

【讨论】:

以上是关于/socket.io/* 404 未找到烧瓶的主要内容,如果未能解决你的问题,请参考以下文章

GET/socket io 未找到 404

获取 http://localhost:3000/socket.io/socket.io.js 404(未找到)

GET http://js:port/socket.io/1/ 404 未找到

GET http://localhost:8080/socket.io/?EIO=3&transport=polling&t=McNiz_D 404(未找到)

/socket.io/socket.io.js 中不提供 Socket.io

Node.js socket.io.js 未找到或 io 未定义