# Websockets (WS) vs Websocket over ActiveMQ
## Goal
- **Websockets or Websocket over MQ** ?
### Websockets (WS)
- No error notification when the client failed to make a connection to the WS server
- Most of error due to **invalid token** (Matrix Token).
- Websockets server can't give error message to the client because the **client is not connected to the websocket server**.
- Alternative solution.
- accept all the incoming connection then validate the token. if not valid then send error message. then close the WS connection.
- ETA : 1 day
- Cons :
- when the client keep repating the same (invalid) token, the server would be exhausted and some ports will be occupied. (limit ports for each server is around 64k)
- **This solution need to be tested (we don't know if there are other errors or not)**. if the client is not connected to the server ( ie. no internet connection ) then the WS server can't send any error message.
- **Can't see any other solution so far**.
### Websockets over ActiveMQ
- Client connect to websocket over ActiveMQ.
- Cons:
- Diffent way to connect to the WS-activeMQ
- I can connect using **Javascript Stomp & Websocket**.
- I don't know about how android & ios connect to WS-activeMQ. (**I assume it's possible**)
- **Authentication has to be handle by ActiveMQ**
- The way to handle **dynamic Authentication** (login using token that connected to the DB) is by developing **ActiveMQ Plugin** (This has to be in **JAVA**, because ActiveMQ is created using **JAVA**).
- The plugin will handle **dynamic authentication** & **one device one connection pattern**.
- Need more research on **Command Handler** (connection between **Python & WS-ActiveMQ**)
- ETA: **~ N/A**
- Command Handler, Python & WS-ActiveMQ connection (and the text message handler) : N/A
- Need to research on finding a library to connecting python and WS-activeMQ (so still can't find library that implement stomp-websocket (ws-over-activeMQ))
- Some Stomp library need to be tried (https://stomp.github.io/implementations.html)
- Authentication (ActiveMQ plugin (JAVA)) : N/A

### Sample
```sequence
Alice->Bob: Hello Bob, how are you?
Note right of Bob: Bob thinks
Bob-->Alice: I am good thanks!
Note left of Alice: Alice responds
Alice->Bob: Where have you been?
```