我使用FCM发送通知,当我使用HTTP时,我的代码运行良好。问题发生在我使用自证书启用SSL时,我无法调用FCM上的主题的subscribe/unsubscribe,错误代码为UNKOWN
。
任何想法这个问题请帮助
我正在尝试调试,这样我就可以获得访问令牌,但不能调用sub/unsubscribe
这是获取访问令牌的请求
2020-12-02T16:06:24.192Z|2|INFO|fcm-demo|c5230eb4f07f582a,9b72559f0d3b8e39,true,|9|task-2|com.google.api.client.http.HttpTransport|curl -v --compressed -X POST -H 'Accept-Encoding: gzip' -H 'User-Agent: Google-HTTP-Java-Client/1.35.0 (gzip)' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -d '@-' -- 'https://oauth2.googleapis.com/token' << $$$
2020-12-02T16:06:24.320Z|2|INFO|fcm-demo|c5230eb4f07f582a,9b72559f0d3b8e39,true,|9|task-2|com.google.api.client.http.HttpTransport|Total: 1,123 bytes
2020-12-02T16:06:24.321Z|2|INFO|fcm-demo|c5230eb4f07f582a,9b72559f0d3b8e39,true,|9|task-2|com.google.api.client.http.HttpTransport|grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&assertion=eyJhbGciOiJSUzI1NiIsImtpZCI6Ijk4NWUyNWI4ODc0ZDkwMDg4NWJjZWJiZWNmMzg2MjVkMTRmYTNhMWUiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJodHRwczovL29hdXRoMi5nb29nbGVhcGlzLmNvbS90b2tlbiIsImV4cCI6MTYwNjkyODc4NCwiaWF0IjoxNjA2OTI1MTg0LCJpc3MiOiJmaXJlYmFzZS1hZG1pbnNkay03bnZvaEBhc2NlbmQtZGV2LXRlc3QuaWFtLmdzZXJ2aWNlYWNjb3VudC5jb20iLCJzY29wZSI6Imh0dHBzOi8vd3d3Lmdvb2dsZWFwaXMuY29tL2F1dGgvZmlyZWJhc2UuZGF0YWJhc2UgaHR0cHM6Ly93d3cuZ29vZ2xlYXBpcy5jb20vYXV0aC91c2VyaW5mby5lbWFpbCBodHRwczovL3d3dy5nb29nbGVhcGlzLmNvbS9hdXRoL2lkZW50aXR5dG9vbGtpdCBodHRwczovL3d3dy5nb29nbGVhcGlzLmNvbS9hdXRoL2RldnN0b3JhZ2UuZnVsbF9jb250cm9sIGh0dHBzOi8vd3d3Lmdvb2dsZWFwaXMuY29tL2F1dGgvY2xvdWQtcGxhdGZvcm0gaHR0cHM6Ly93d3cuZ29vZ2xlYXBpcy5jb20vYXV0aC9kYXRhc3RvcmUifQ.jnqKQhzxSkSvX5aKumAN1sJPk07l-IWYfCVi5O_Pxh4SQ0-mSrBEdtUXIXKilECB6Mdhg7dMu4zjewUHaFFLfqT6JYnZkAX3ByjKxjW6IP0RdclxV_cN8H-RRmgQkIdm5NX5OgfvGMZskU-Pwoly5QRVoppnJfr5tndbBCkXdB1FTdzcQr61yAnzGfb9b4NDXFeLrftQzMs2psRxtswIluryjOt_uZoaxyc0NRU3iVc28pKIuGH5z6wAQMfVUtySyec0jdgzPMA2ppGL6Jp8ZwVL7tpbPeKZvWfHgeAVVoFUgCqn8bdvmJ0skGKJjZrkzpjNcDhMJLcM78ZPRmsU_A
2020-12-02T16:06:24.358Z|2|INFO|fcm-demo|c5230eb4f07f582a,9b72559f0d3b8e39,true,|9|task-2|com.google.api.client.http.HttpTransport|-------------- RESPONSE --------------
HTTP/1.1 200 OK
这是呼叫订阅主题的请求
2020-12-02T16:06:24.394Z|2|INFO|fcm-demo|c5230eb4f07f582a,9b72559f0d3b8e39,true,|9|task-2|com.google.api.client.http.HttpTransport|-------------- REQUEST --------------
POST https://iid.googleapis.com/iid/v1:batchAdd
Accept-Encoding: gzip
Authorization: <Not Logged>
User-Agent: Google-HTTP-Java-Client/1.35.0 (gzip)
access_token_auth: true
Content-Type: application/json; charset=UTF-8
Content-Length: 217
2020-12-02T16:06:24.394Z|2|INFO|fcm-demo|c5230eb4f07f582a,9b72559f0d3b8e39,true,|9|task-2|com.google.api.client.http.HttpTransport|curl -v --compressed -X POST -H 'Accept-Encoding: gzip' -H 'Authorization: <Not Logged>' -H 'User-Agent: Google-HTTP-Java-Client/1.35.0 (gzip)' -H 'access_token_auth: true' -H 'Content-Type: application/json; charset=UTF-8' -d '@-' -- 'https://iid.googleapis.com/iid/v1:batchAdd' << $$$
2020-12-02T16:06:24.455Z|2|ERROR|fcm-demo|c5230eb4f07f582a,9b72559f0d3b8e39,true,|9|task-2|c.a.a.fcm-demo.client.FirebaseClient|Subscribe to topic [topic-0019] - failed with error code [UNKNOWN], messaging error code [null], message [Unknown error while making a remote service call: Connection reset]
我不明白的是,我可以获得访问令牌,但不能调用sub/unsubscribe API
注:
- 网络应该没有问题,因为我获得了访问令牌
- 自我认证可能不会出现问题,因为我可以与OAuth API通信以获取令牌(不确定,因为OAuth与iid google实例可能需要不同的TLS(
ENV/Lib:
- 弹簧套2.1.18
- firebase-admin.version.7.0.1
我已经解决了这个问题。
与防火墙有关的问题,我甚至打开了所有的,但没有工作,但当我添加2个谷歌API的URL时(OAuth和iid.googleapis.com(。它有效。
但我仍然不确定为什么我可以打电话给OAuth,但却打电话给
谢谢大家