私は最近、私のプッシャーエラーログで見て気づいた:一般的な私たちの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);
}
このエラーが発生しますバックエンド?
そのアプリが認証エンドポイントのURLを設定する必要があり@chasenyc(HTTPS([設定のドキュメントで 'AuthMethod.endpoint']を参照してください。 //github.com/pusher/pusher-websocket-swift#configuration))。私はそのURLのサーバーが無効な認証サインを生成していると思います。どのライブラリを使用していますか? – jameshfisher
@chasenycバックエンド。 'AuthMethod.endpoint'(おそらくこれが本番アプリの場合)を使用している場合、無効な署名が認証URLでバックエンドによって生成されている可能性があります。あなたは 'AuthMethod.endpoint'を使っていますか? – jameshfisher
@chasenyc私は私の答えを更新しました。 – jameshfisher