title: Expected HTTP 101 response but was '200 OK' when trying to connect echo/websocket
body: <p>I am just working on an android application written in native Java. I am using a server in this application so I am working with WebSockets.
  I am getting this error</p>
  <pre><code>java.net.ProtocolException: Expected HTTP 101 response but was '200 OK'
  </code></pre>
  <p>while trying to connect to ws://echo.websocket.org and I don't know why. I am new to working with WebSockets so I am really lost on that one.</p>
  <p>That's my activity where I try to establish the connection. The important part is in InitiateSocketConnection() function</p>
  <pre><code>    package com.example.rockpaperscissors;
  
  import androidx.annotation.Nullable;
  import androidx.appcompat.app.AppCompatActivity;
  import androidx.recyclerview.widget.LinearLayoutManager;
  import androidx.recyclerview.widget.RecyclerView;
  
  import android.os.Bundle;
  import android.widget.Toast;
  
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import okhttp3.OkHttpClient;
  import okhttp3.Request;
  import okhttp3.Response;
  import okhttp3.WebSocket;
  import okhttp3.WebSocketListener;
  
  public class Loby extends AppCompatActivity {
  
  
  private String name;
  private WebSocket webSocket;
  private String Server_Path = &quot;ws://echo.websocket.org&quot;;
  private RecyclerView recyclerView;
  private PlayersAdapter playersAdapter;
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_loby);
  
      name = getIntent().getStringExtra(&quot;name&quot;);
      InitiateSocketConnection();
      
  }
  
  private void InitiateSocketConnection() {
  
      OkHttpClient client = new OkHttpClient().newBuilder().build();
      Request request = new Request.Builder().url(Server_Path).build();
      webSocket = client.newWebSocket(request,new Socket_Listener());
  
      client.dispatcher().executorService().shutdown();
  }
  
  private class Socket_Listener extends WebSocketListener
  {
      @Override
      public void onOpen(WebSocket webSocket, Response response) {
          super.onOpen(webSocket, response);
          runOnUiThread(()-&gt;
          {
              Toast.makeText(Loby.this,&quot;Socket connected successfully!&quot;,Toast.LENGTH_LONG).show();
              initializeView();
          });
      }
  
      @Override
      public void onMessage(WebSocket webSocket, String text) {
          super.onMessage(webSocket, text);
      }
  
      @Override
      public void onFailure(WebSocket webSocket, Throwable t, @Nullable Response response) {
          super.onFailure(webSocket, t, response);
          runOnUiThread(()-&gt;
          {
              Throwable err = t;
              Toast.makeText(Loby.this, &quot;Socket was not connected!&quot;, Toast.LENGTH_LONG).show();
          });
      }
  }
  
  private void initializeView() {
      recyclerView = findViewById(R.id.name_list);
      playersAdapter = new PlayersAdapter(getLayoutInflater());
      recyclerView.setAdapter(playersAdapter);
      recyclerView.setLayoutManager(new LinearLayoutManager(this));
  
      JSONObject jsonObject = new JSONObject();
      try {
          jsonObject.put(&quot;name&quot;,name);
          playersAdapter.addItem(jsonObject);
  
          webSocket.send(jsonObject.toString());
  
      } catch (JSONException e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  <p>}</p>
  <p>I don't think that's the issue but I permitted internet in manifest and this is my relevant implantation on the build.Gradle:</p>
  <pre><code> implementation 'com.squareup.okhttp3:okhttp:3.10.0'
  </code></pre>
  <p>Thanks!</p>