Skip to content

Commit

Permalink
Merge pull request #50 from costasko/fix_readme_example
Browse files Browse the repository at this point in the history
working examples with on_open callback and sslopts
  • Loading branch information
Fitblip authored Aug 12, 2021
2 parents aabe622 + 85a4436 commit d9b1044
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 d9b1044

Please sign in to comment.