Skip to content

Commit

Permalink
working examples with on_open callback and sslopts
Browse files Browse the repository at this point in the history
  • Loading branch information
costasko committed Aug 10, 2021
1 parent aabe622 commit 85a4436
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ import certstream
def print_callback(message, context):
print("Received messaged -> {}".format(message))

def on_open(instance):
# Instance is the CertStreamClient instance that was opened
def on_open():
print("Connection successfully established!")

def on_error(instance, exception):
Expand All @@ -80,6 +79,14 @@ certstream.listen_for_events(print_callback, url='wss://certstream.calidog.io/',

Need more connection options? Take a look at `**kwargs` in `certstream.listen_for_events`. We pass it to `run_forever` method of [websocket-client](https://github.com/websocket-client/websocket-client/blob/87861f951d1a65ed5d9080f7aaaf44310f376c56/websocket/_app.py#L169-L192).

e.g. to skip SSL/TLS verification
```python
import certstream
import ssl

certstream.listen_for_events(print_callback, url='wss://certstream.calidog.io/', sslopt={"cert_reqs":ssl.CERT_NONE})
```

# Example data structure

The data structure coming from CertStream looks like this:
Expand Down

0 comments on commit 85a4436

Please sign in to comment.