2017-05-19 22 views
0

私は最近、私のプッシャーエラーログで見て気づいた:一般的な私たちのWebSocketをにプッシャークライアントエラー:無効な署名

Invalid signature: Expected HMAC SHA256 hex digest of 217478.6054950:private-production1_xxxxx_1232:{"user_id":xxxx}, but got 707d39519ca7f971a134524d8fe2ebafbddd64f42b6af0a20d6a73fxxxxxxx

は正常に動作しています。私たちは多くのクライアントが完全に正常に動作しており、ソケットは一般的に問題なく動作しているようです。私がこのエラーに気付いたのはこれが初めてで、エラーログをかなり頻繁にチェックします。これは私が気にするべきことですか?私はprivateチャンネルが一般的に適切に動作していることを確認できます。次のようにフロントエンドに

コードは次のとおりです。

バックエンド(Laravelアプリケーション)で
let options = PusherClientOptions(
    authMethod: AuthMethod.authRequestBuilder(authRequestBuilder: AuthRequestBuilder() 
) 
pusher = Pusher(key: pusherKey!, options: options) 

class AuthRequestBuilder: AuthRequestBuilderProtocol { 
    func requestFor(socketID: String, channel: PusherChannel) -> NSMutableURLRequest? { 
    let request = NSMutableURLRequest(url: URL(string: "https://\(baseURLPrefix).xxxxxx.com/xxxxx/xxxxx")!) 
    request.httpMethod = "POST" 
    request.httpBody = "socket_id=\(socketID)&channel_name=\(channel.name)".data(using: String.Encoding.utf8) 
    request.addValue(
     "Bearer " + authToken, forHTTPHeaderField: "Authorization" 
    ) 
    return request 
    } 
} 

:彼らは私たちに悪いベアラトークンを通過した場合

// Controller 

public function presence_auth(Request $request) 
{ 
    $pusher = new Pusher(
     config('broadcasting.connections.pusher.key'), 
     config('broadcasting.connections.pusher.secret'), 
     config('broadcasting.connections.pusher.app_id') 
    ); 

    return $pusher->presence_auth($request->input('channel_name'), $request->input('socket_id'), AuthUser()->id); 
} 

このエラーが発生しますバックエンド?

答えて

0

$pusher->presence_authを使用して、プライベートチャネル、つまり接頭辞付きチャネルprivate-の署名を作成しています。しかし、presence_authは、プレゼンスチャネル、すなわち接頭辞がpresence-のチャネルを認証することを目的としています。

プレゼンスデータを使用する場合は、presence-のチャネルプレフィックスを使用できます。あなたは、プレゼンス情報なしprivate-チャネルを使用したい場合は、あなただけ使用することができます。

$pusher->socket_auth($request->input('channel_name'), $request->input('socket_id')) 
+0

そのアプリが認証エンドポイントのURLを設定する必要があり@chasenyc(HTTPS([設定のドキュメントで 'AuthMethod.endpoint']を参照してください。 //github.com/pusher/pusher-websocket-swift#configuration))。私はそのURLのサーバーが無効な認証サインを生成していると思います。どのライブラリを使用していますか? – jameshfisher

+0

@chasenycバックエンド。 'AuthMethod.endpoint'(おそらくこれが本番アプリの場合)を使用している場合、無効な署名が認証URLでバックエンドによって生成されている可能性があります。あなたは 'AuthMethod.endpoint'を使っていますか? – jameshfisher

+0

@chasenyc私は私の答えを更新しました。 – jameshfisher