【问题标题】:/socket.io/* 404 not found flask/socket.io/* 404 未找到烧瓶
【发布时间】: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

【问题讨论】:

    标签: python flask socket.io


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-08
      • 1970-01-01
      • 2021-01-18
      • 2017-12-08
      • 2017-09-27
      • 2013-11-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多