Top Banner
Realtime web: Not there yet! Marek Majkowski [email protected] 1
61

Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

Jul 22, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

Realtime web:Not there yet!

Marek Majkowski

[email protected]

1

Page 2: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

Nogi

2

Page 3: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

3

Page 4: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

4

Page 5: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

5

Page 6: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

6

Page 7: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

7

Page 8: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

WebSockets

hixie-75 4 5.0.0

hixie-76 4 (disabled)

6 5.0.1 11 (disabled)

hybi-07 6

hybi-10 7 14 10-dev

8

Page 9: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

Spot the difference!$ nc localhost 12345GET /echo HTTP/1.1Origin: http://172.16.173.128:12345Host: 172.16.173.128:12345Connection: UpgradeUpgrade: WebSocketSec-WebSocket-Key2: `1]2037 7 GX 'f<Vb1*5$64Sec-WebSocket-Key1: 2Uf ?<,4C28E1K7J4+208Cookie2: $Version=1Cookie: JSESSIONID=a

aaaaaaaaaaaaaaaHTTP/1.1 101 WebSocket Protocol HandshakeUpgrade: WebSocketConnection: UpgradeSec-WebSocket-Location: ws://[...]Sec-WebSocket-Origin: http://[...]

m"7]SDgo0^C

$ nc localhost 8080GET /broadcast/765/321/websocket HTTP/1.1Origin: http://172.16.173.128:8080Host: 172.16.173.128:8080Connection: UpgradeUpgrade: WebSocketSec-WebSocket-Key2: `1]2037 7 GX 'f<Vb1*5$64Sec-WebSocket-Key1: 2Uf ?<,4C28E1K7J4+208Cookie2: $Version=1Cookie: JSESSIONID=a

aaaaaaaaaaaaaaaHTTP/1.1 101 WebSocket Protocol HandshakeUpgrade: websocketConnection: UpgradeSec-WebSocket-Location: ws://[...] Sec-WebSocket-Origin: http://[...]

m"7]SDgo0^C

9

Page 10: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

The RFC says

-> If the entry's name is "upgrade" If the value is not exactly equal to the string "WebSocket", then fail the WebSocket connection and abort these steps.

[...]

|Upgrade| The value must be the string "WebSocket".

[...]

|Upgrade| Invariant part of the handshake. Will always have a value that is an ASCII case-insensitive match for the string "WebSocket".

10

Page 11: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

ProxiesCONNECT sockjs1.popcnt.org:80 HTTP/1.1Host: sockjs1.popcnt.orgProxy-Connection: keep-alive

GET /echo/855/duzzy2p1/websocket HTTP/1.1Upgrade: WebSocketConnection: UpgradeHost: sockjs1.popcnt.orgOrigin: http://sockjs.popcnt.orgSec-WebSocket-Key1: 22p/ D"47900%n7 r90.Sec-WebSocket-Key2: m49" 5 f 24772 Ra 0

GET /echo/070/lm6wwjpr/websocket HTTP/1.1Host: sockjs1.popcnt.orgUser-Agent: [...] Gecko/20100101 Firefox/6.0.2Accept: text/html,application/xhtml [...]Accept-Language: en-us,en;q=0.5Accept-Encoding: gzip, deflateAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7Sec-WebSocket-Version: 7Sec-WebSocket-Origin: http://sockjs.popcnt.orgSec-WebSocket-Key: bzG4fOYXabSiy42uFj6vjA==Pragma: no-cacheCache-Control: no-cacheUpgrade: websocketConnection: Upgrade

HTTP/1.0 400 Bad RequestServer: squid/2.7.STABLE9Date: Wed, 21 Sep 2011 06:16:10 GMTContent-Type: text/htmlContent-Length: 1943X-Squid-Error: ERR_INVALID_REQ 0X-Cache: MISS from mrstuX-Cache-Lookup: NONE from mrstu:3128Via: 1.0 mrstu:3128 (squid/2.7.STABLE9)Connection: close

11

Page 12: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

• #1 Realtime web: Not there yet!

12

Page 13: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

Shared nothing + database

13

Page 14: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

Shared nothing + message bus

14

Page 15: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

Node.js + Socket.io

15

Page 16: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

Sync + Async

16

Page 17: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

Sync + Service

17

Page 18: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

18

Page 19: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

Google App Engine

19

Page 20: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

Google App Engine

• Simplex

19

Page 21: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

Google App Engine

• Simplex

• No broadcast

19

Page 22: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

Google App Engine

• Simplex

• No broadcast

• No presence

19

Page 23: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

PubNub

20

Page 24: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

PubNub

• Duplex

20

Page 25: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

PubNub

• Duplex

• Broadcast

20

Page 26: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

PubNub

• Duplex

• Broadcast

• No access rights

20

Page 27: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

PubNub

• Duplex

• Broadcast

• No access rights

• No identity

20

Page 28: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

Pusher

21

Page 29: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

Pusher

• Simplex

21

Page 30: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

Pusher

• Simplex

• Broadcast

21

Page 31: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

Pusher

• Simplex

• Broadcast

• Access rights *

21

Page 32: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

Pusher

• Simplex

• Broadcast

• Access rights *

• Identity *

21

Page 33: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

Pusher

• Simplex

• Broadcast

• Access rights *

• Identity *

• Presence *

21

Page 34: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

We can do better

22

Page 35: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

We can do better

• Duplex

22

Page 36: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

We can do better

• Duplex

• Broadcast

22

Page 37: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

We can do better

• Duplex

• Broadcast

• Access rights

22

Page 38: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

We can do better

• Duplex

• Broadcast

• Access rights

• Identity

22

Page 39: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

We can do better

• Duplex

• Broadcast

• Access rights

• Identity

• Presence

22

Page 40: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

23

Page 41: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

• Authorisation

23

Page 42: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

• Authorisation

• Identity

23

Page 43: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

• Authorisation

• Identity

• Permissions

23

Page 44: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

• Authorisation

• Identity

• Permissions

• Resource definitions + semantics

23

Page 45: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

• Authorisation

• Identity

• Permissions

• Resource definitions + semantics

• Value + updates?

23

Page 46: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

• Authorisation

• Identity

• Permissions

• Resource definitions + semantics

• Value + updates?

• Messages back to App (WebHooks)

23

Page 47: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

• Authorisation

• Identity

• Permissions

• Resource definitions + semantics

• Value + updates?

• Messages back to App (WebHooks)

• Presence

23

Page 48: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

• Authorisation

• Identity

• Permissions

• Resource definitions + semantics

• Value + updates?

• Messages back to App (WebHooks)

• Presence

• Good luck writing documentation!

23

Page 49: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

Service?

24

Page 50: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

Sync + Async

25

Page 51: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

Fully async

26

Page 52: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

SockJS

27

Page 53: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

• #3 Realtime web: Not there yet!

28

Page 54: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

29

Page 55: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

30

Page 56: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

#sockjs

github.com/sockjs31

Page 57: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

1. token

32

Page 58: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

2. token

33

Page 59: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

3. token

34

Page 60: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

So?

35

Page 61: Realtime web: Not there yet! · Node.js + Socket.io 15. Sync + Async 16. Sync + Service 17. 18. Google App Engine 19. Google App Engine

36