Proxy Service Configuration Guide
All myPOS Smart POS devices come with prepaid SIM cards that provide internet connectivity for payment processing and myPOS applications. However, if your Android application needs to communicate with your own servers or any 3rd party APIs while using the SIM card connectivity, you must route this communication through the myPOS Proxy service.
When connected to a WiFi network, 3rd party services are directly reachable without the proxy. The proxy is only required for communication over the SIM card connection.
Proxy Configuration
To connect your application to external servers via the myPOS SIM card, use the following proxy settings:
| Parameter | Production | Test/Sandbox | Description |
|---|---|---|---|
| Proxy Host | cgs.mypos.com | cgst.mypos.com | The proxy server address for your environment |
| Proxy Port | 8443 | 8443 | TCP port for proxy connections |
| Username | Contact Support | developers | Proxy authentication username |
| Password | Contact Support | 7S44Ya950yfa | Proxy authentication password |
| Authentication | HTTP Basic Auth | HTTP Basic Auth | Authentication method via Proxy-Authorization header |
Allowed Hosts
The myPOS proxy allows connections to the following hosts:
*.amazonaws.com- Amazon Web Services*.python.org- Python official sites*.pypi.org- Python Package Indexlogin.microsoftonline.com- Microsoft authentication*.google.com- Google services
If your application needs to access hosts not included in this list, please contact myPOS technical support to request allowlist additions.
Implementation Examples
This example shows how to configure OkHttp on Android to use an HTTP proxy with Basic authentication. The proxy is defined using Proxy.Type.HTTP and credentials are sent via the Proxy-Authorization header.
For HTTPS traffic, OkHttp automatically uses the CONNECT method through the proxy.
import okhttp3.* import java.net.* import java.util.concurrent.TimeUnit class ProxyExample { private val proxyHost = "cgst.mypos.com" private val proxyPort = 8443 private val proxyUser = "developers" private val proxyPass = "7S44Ya950yfa" fun testRequest() { val proxy = Proxy( Proxy.Type.HTTP, InetSocketAddress(proxyHost, proxyPort) ) val client = OkHttpClient.Builder() .proxy(proxy) .proxyAuthenticator { _, response -> val credential = Credentials.basic(proxyUser, proxyPass) response.request.newBuilder() .header("Proxy-Authorization", credential) .build() } .connectTimeout(15, TimeUnit.SECONDS) .readTimeout(20, TimeUnit.SECONDS) .build() val request = Request.Builder() .url("https://www.google.com/") .get() .build() try { val response = client.newCall(request).execute() println("HTTP ${response.code}") println(response.body?.string()) response.close() } catch (e: Exception) { e.printStackTrace() } } }
Key Implementation Details
1. Proxy Configuration
- Set the proxy type to
Proxy.Type.HTTP - Configure the proxy host (
cgst.mypos.com) and port (8443) - Use
InetSocketAddressto create the proxy address
2. Authentication
- Implement
proxyAuthenticatorto handle authentication - Use
Credentials.basic()to encode username and password - Add credentials to the
Proxy-Authorizationheader
3. Timeouts
- Connect Timeout: 15 seconds (time to establish connection)
- Read Timeout: 20 seconds (time to read response data)
- Adjust these values based on your application's requirements
4. HTTPS Support
- The proxy automatically handles HTTPS traffic using the HTTP CONNECT method
- No additional configuration needed for SSL/TLS connections
- All encrypted traffic passes securely through the proxy tunnel
Best Practices
| Best Practice | Description |
|---|---|
| Check Network Type | Detect if the device is using WiFi or SIM card connectivity, and only apply proxy settings when using SIM |
| Handle Errors Gracefully | Implement proper error handling for proxy connection failures, authentication errors, and timeouts |
| Secure Credentials | Store proxy credentials securely, avoid hardcoding in production code |
| Test Both Modes | Test your application with both WiFi and SIM card connectivity to ensure proper proxy switching |
| Connection Pooling | Reuse the configured OkHttpClient instance across your application for better performance |
Troubleshooting
Common Issues
Connection Timeout
- Verify proxy host and port are correct
- Check that the device has active SIM card connectivity
- Increase timeout values if network is slow
Authentication Failed (407 Error)
- Confirm username and password are correct
- Ensure
Proxy-Authorizationheader is properly set - Check that
proxyAuthenticatoris configured
HTTPS Not Working
- Verify that OkHttp version supports CONNECT method
- Check that target server supports HTTPS
- Ensure SSL certificates are valid
Works on WiFi but Not on SIM
- Confirm proxy configuration is only applied for SIM connectivity
- Verify SIM card has active data connection
- Check that myPOS proxy service is accessible
Need Help?
If you encounter issues with the proxy service or need additional support:
- Check the Smart SDK documentation for more integration details
- Contact myPOS technical support for proxy-related questions
- Review your network configuration and connectivity settings