I have written a code to mine a pool using stratum protocol. The code is as follows:
public static void main(String[] args)
{
    connectToPool("stratum.slushpool.com", 3333);
}   
static void connectToPool(String host, int port)
{
    try
    {
        InetAddress address = InetAddress.getByName(host);
        out.println("Atempting to connect to " + address.toString() + " on port " + port + ".");
        socket = new Socket(address, port);
        String message1 = "{\"jsonrpc\" : \"2.0\", \"id\": 1, \"method\": \"mining.subscribe\", \"params\": []}";
        PrintWriter output = new PrintWriter(socket.getOutputStream(), true);
        BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        output.write((message1 + "\\n"));
        out.println(input.readLine());//Hangs here.
    }
    catch (IOException e)
    {
        out.println(e.getMessage());
        out.println("Error. Can't connect to Pool.");
        System.exit(-2);
    }
}
I am supposed to get a response back but when I run this code, I don’t receive any response. What am I doing?