I have a case in my setup which requires to connect from my app server to FCM since this is not allowed directly from app server and I already have HAProxy so I’m planning to use it as a forward proxy, FCM admin SDK support this via configuration where I can configure HAProxy as a proxy when I put IP and and Port I made already those changes in SDK
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(HAProxy_hostname,HAProxy_port));
HttpTransport httpTransport = new NetHttpTransport.Builder()
.setProxy(proxy)
.build();
GoogleCredentials googleCredentials = GoogleCredentials.fromStream(googleCredentialsConfigurationStream,() -> httpTransport);
FirebaseOptions firebaseOptions = FirebaseOptions
.builder()
.setHttpTransport(httpTransport)
.setCredentials(googleCredentials)
.build();
FirebaseApp.initializeApp(firebaseOptions);
Also applied some configuration on HAProxy side as below, but I got an error related to following Unknown error while making a remote service call: Error getting access token for service account: Unexpected end of file from server, iss: firebase-adminsdk-2653537
frontend fcmproxy_frontend
bind *:8084 transparent
#stats uri /haproxy?stats
default_backend fcm_backend
mode tcp
option tcplog
tcp-request content accept if HTTP
tcp-request inspect-delay 10s
backend fcm_backend
mode tcp
timeout tunnel 3000s
server FCM aws.com verify none #dummy URL since server is not used in this case instead it should use request hostname
Can you spot in any of the errors in the following configuration ?