Web Sockets now shipping in OkHttp 3.5!

Jake Wharton
Dec 2, 2016 · 2 min read

Heads up, we’ve moved! If you’d like to continue keeping up with the latest technical content from Square please visit us at our new home https://developer.squareup.com/blog

Unlike the traditional request/response model of HTTP, web sockets provide fully bi-directional streaming of messages. This means that both the client and the server can send any number of messages to the other peer at any time. With today’s version 3.5 release, OkHttp now offers native support for web sockets!

OkHttpClient client = new OkHttpClient();Request request = //...
WebSocketListener listener = //...
WebSocket ws = client.newWebSocket(request, listener);
compile 'com.squareup.okhttp3:okhttp:3.5.0

Square Corner Blog

Buying and selling sound like simple things - and they…

Jake Wharton

Written by

Stop stopping.

Square Corner Blog

Buying and selling sound like simple things - and they should be. Somewhere along the way, they got complicated. At Square, we're working hard to make commerce easy for everyone.

Jake Wharton

Written by

Stop stopping.

Square Corner Blog

Buying and selling sound like simple things - and they should be. Somewhere along the way, they got complicated. At Square, we're working hard to make commerce easy for everyone.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store