Sockets Java API Overview
Beta
This is a Beta release of the Sockets API. This API is not covered by any SLA or deprecation policy and may be subject to backward-incompatible changes.
Sockets are only available for paid apps, and traffic from sockets is billed as outgoing bandwidth. Sockets are also limited by daily and per minute (burst) quotas. App Engine supports regular outbound Java sockets such as java.net.Socket and java.net.DatagramSocket.
There is currently no support for sockets via java.nio.SocketChannel or other java.nio classes. The Sockets API allows client code to call get/set options against sockets. (Previously, calls raised Not Implemented exceptions.)
The currently supported options are:
SO_KEEPALIVESO_DEBUGTCP_NODELAYSO_LINGERSO_OOBINLINESO_SNDBUFSO_RCVBUFSO_REUSEADDR
Limitations and restrictions
Although App Engine supports sockets, there are certain limitations and behaviors you need to be aware of when using sockets:
Sockets are available only for paid apps.
You cannot create a listen socket; you can only create outbound sockets.
FTP is not supported.
java.net.URLis still configured to use the URL Fetch API; there is currently no way around this.InetAddress.isReachable is a no-op.
Most classes in
javax.net.sslare supported.You can only use TCP or UDP; arbitrary protocols are not allowed.
You cannot bind to specific IP addresses or ports.
Port 25 (SMTP) is blocked; you can still use authenticated SMTP on the submission port 587.
Private, broadcast, multicast, and Google IP ranges (except those whitelisted below), are blocked:
Google Public DNS:
8.8.8.8,8.8.4.4,2001:4860:4860::8888,2001:4860:4860::8844port 53Gmail SMTPS:
smtp.gmail.comport 465 and 587Gmail POP3S:
pop.gmail.comport 995Gmail IMAPS:
imap.gmail.comport 993
Note: Google Compute Engine IP addresses are not considered to be in Google IP ranges. You can use sockets to connect Google App Engine apps to Google Compute Engine instances.
Socket descriptors are associated with the App Engine app that created them and are non-transferable (cannot be used by other apps).
Sockets may be reclaimed after 2 minutes of inactivity; any socket operation keeps the socket alive for a further 2 minutes.
You cannot
Selectbetween multiple available sockets because that requiresjava.nio.SocketChannelwhich is not currently supported.)
Using sockets with the development server
You can run and test code using sockets on the development server, without using any special command line parameters.
App Engine sample using sockets
For a sample using sockets, see the socket demo app in the Google Cloud Platform GitHub.
