The background service that handles the communication times out when opening the socket. Now that I thought about this problem again, it may be an OS version issue. The devices the app will be run on have Marshmallow, the others have Nougat.