java.net.ProtocolException: Expected HTTP 101 response but was ‘500 Internal Server Error’

Today I found a problem in our Jenkins instance. the build is failing, I checked the log on jenkins master and found the following:

 12:11:18 java.net.ProtocolException: Expected HTTP 101 response but was '500 Internal Server Error'
12:11:18 	at okhttp3.internal.ws.RealWebSocket.checkResponse(RealWebSocket.java:219)
12:11:18 	at okhttp3.internal.ws.RealWebSocket$2.onResponse(RealWebSocket.java:186)
12:11:18 	at okhttp3.RealCall$AsyncCall.execute(RealCall.java:153)
12:11:18 	at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
12:11:18 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
12:11:18 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
12:11:18 	at java.lang.Thread.run(Thread.java:748)

It looks like jenkins agent is not able to talk to jenkins master. so agent thur out a 500 error. After the investigation I found out that was due to the network policy that my colleague was testing.

During the troubleshooting, I found someone else had the same problem. and Jenkins official answers this supposed to be a kubernetes issue rather than jenkins. So this also explains.