2017-04-22 47 views
0

我用的Redis和socket.io.It失敗的存在和私人渠道我用的Redis和socket.io.It失敗的存在和私人渠道

laravel回聲工作我使用laravel回聲工作這個包我的服務器laravel-echo-server

一切正常,當我使用公共信道,但是當我用下面的錯誤民間渠道被記錄在laravel回波服務器

 Client can not be authenticated, got HTTP status 503 
⚠ [7:16:00 PM] - 155BcZ4cC_ieweeWAAAD could not be authenticated to presence-chat-message      

</style> 
</head><body id=ERR_CONNECT_FAIL> 
<div id="titles"> 
<h1>ERROR</h1> 
<h2>The requested URL could not be retrieved</h2> 
</div> 
<hr> 

<div id="content"> 
<p>The following error was encountered while trying to retrieve the URL: <a href       ="http://localhost:8000/broadcasting/auth">http://localhost:8000/broadcasting/au       th</a></p> 

<blockquote id="error"> 
<p><b>Connection to 127.0.0.1 failed.</b></p> 
</blockquote> 

<p id="sysmsg">The system returned: <i>(111) Connection refused</i></p> 

<p>The remote host or network may be down. Please try the request again.</p> 

<p>Your cache administrator is <a href="mailto:webmaster?subject=CacheErrorInfo%       20-%20ERR_CONNECT_FAIL&amp;body=CacheHost%3A%20routingserver-ProLiant-ML10-v2%0D       %0AErrPage%3A%20ERR_CONNECT_FAIL%0D%0AErr%3A%20(111)%20Connection%20refused%0D%0       ATimeStamp%3A%20Sat,%2022%20Apr%202017%2013%3A46%3A07%20GMT%0D%0A%0D%0AClientIP%       3A%20172.16.0.69%0D%0AServerIP%3A%20localhost%0D%0A%0D%0AHTTP%20Request%3A%0D%0A       POST%20%2Fbroadcasting%2Fauth%20HTTP%2F1.1%0AX-CSRF-TOKEN%3A%20vASD32FqeyddyxVxE       2xIEwV59kjxgETldK9cLIXh%0D%0ACookie%3A%20Elgg_install%3Dk67c3s96b6ddp8pubp2g6lvt       31%3B%20Elgg%3D5ncfp6re96lj5mron6nrmcjlf4%3B%20PHPSESSID%3Dj92vr9dsqq63o9q9a9q5t       bu5q1%3B%20Phpstorm-4bea889c%3D96279c8c-c2d7-4275-8185-4e2526d58f0e%3B%20io%3DmT       Kxolc1pbd-AO8CAAAC%3B%20XSRF-TOKEN%3DeyJpdiI6InM0eWxhMFlhYXlBb3BZVTQ5SThhNnc9PSI       sInZhbHVlIjoiTFpObHVaZ2RtQzlyd0VvYnJHbVNYaDlsOStkcmxFeHo0SEJFTzlqcE01NTVpMDRyY1B       3blRnN3ZnaHhaQzZLUVRXWWNKTGl3RDVFQWhIQnNlSjBhVEE9PSIsIm1hYyI6ImYzYjI4NjgwY2I3YmZ       jOGExNGM1ZjYzOGMwZDc2MzQwNjI5YmE4ZmUzMTJhNmRhMjk4MzkzZDJjMWRiZmM0MzgifQ%253D%253       D%3B%20laravel_session%3DeyJpdiI6ImRsd3RNaWpnVWhDUGdqREgxVlNBeFE9PSIsInZhbHVlIjo       iQmxZQXl6bWQyN1dxM3QrZmhSdlRYK0ZxdHNpMFNKNnBXbytQQ1piREJmZWN5VHJDS2JXUXRWcjlkaVQ       xRnBxdUdMM093czY5ZGw2S0xyb1NtWUNCbGc9PSIsIm1hYyI6Ijg0MDRjN2Q2MDRjMDYwYTc4MTQyZDU       2MzU3MzZkZTc5NDkzZTM3OWEzMjVhM2MyYmFlZjVhZGQ1YzJkNjliNWUifQ%253D%253D%0D%0AX-Req       uested-With%3A%20XMLHttpRequest%0D%0AContent-Type%3A%20application%2Fx-www-form-       urlencoded%0D%0AProxy-Authorization%3A%20Basic%20dWVtOjEyMzQ1%0D%0AContent-Lengt       h%3A%2034%0D%0AConnection%3A%20close%0D%0AHost%3A%20localhost%3A8000%0D%0A%0D%0A       %0D%0A">webmaster</a>.</p> 

<br> 
</div> 

<hr> 
<!-- ERR_CONNECT_FAIL --> 
</div> 
</body></html> 

以下是我app.js, bootstrap.js和laravel回波-server.json

const app = new Vue({ 
    el: '#app', 

    data:{ 
     messages:[], 

    }, 

    mounted:function() { 

    axios.get('/message/2').then(response =>{ 

    for(i in response.data) 
    { 
     this.messages.push(response.data[i]); 
    } 

    }); 

    Echo.join('chat-message') 
    .listen('MessageSentEvent', (data) => { 

     console.log(data); 

    }); 

    console.log("Done loading "); 
    }, 

    methods:{ 

    addMessage(message) { 
     // console.log(this.messages); 
     this.messages.push(message); 
     axios.post("ajax/message/send",message).then(response =>{ 
     }); 



     console.log('Added Message'); 
    } 
} 


    });`` 

bootstrap.js

import Echo from "laravel-echo" 

    window.Echo = new Echo({ 
    broadcaster: 'socket.io', 
    host: 'http://localhost:6001', 

    }); 

laravel回波-server.json

{ 
"authHost": "http://localhost:8000", 
"authEndpoint": "/broadcasting/auth", 
"clients": [ 
    { 
     "appId": "c6efc75749e6d774", 
     "key": "6a0910dcc0073a83d06df25ebc2590dc" 
    }, 
    { 
     "appId": "0c35b8cc253e901e", 
     "key": "0c5c4f54754818ccf2ac0fc3f67809b5" 
    } 
], 
"database": "redis", 
"databaseConfig": { 
    "redis": { 
     "host": "127.0.0.1", 
     "password": "prince", 
     "port": "6379" 
    }, 
    "sqlite": { 
     "databasePath": "/database/laravel-echo-server.sqlite" 
    } 
}, 
"devMode": true, 
"host": "localhost", 
"port": "6001", 
"protocol": "http", 
"socketio": {}, 
"sslCertPath": "", 
"sslKeyPath": "" 
} 

回答

0

作爲每laravel-echo-server.json你已經添加了auth主機路由,所以當你連接laravel echo服務器時,它會檢查t他驗證路由響應以驗證授權。 http://localhost:8000//broadcasting/auth它不工作,因此您收到此錯誤,創建路由Route::post('broadcastAuth','[email protected]');

檢查該回購套接字演示https://github.com/karoys/laravel-echo-server-vuejs