Giter VIP home page Giter VIP logo

tutorials's Introduction

Ably


Tutorials repository

Ably is the platform that powers synchronized digital experiences in realtime. Whether attending an event in a virtual venue, receiving realtime financial information, or monitoring live car performance data – consumers simply expect realtime digital experiences as standard. Ably provides a suite of APIs to build, extend, and deliver powerful digital experiences in realtime for more than 250 million devices across 80 countries each month. Organizations like Bloomberg, HubSpot, Verizon, and Hopin depend on Ably’s platform to offload the growing complexity of business-critical realtime data synchronization at global scale. For more information, see the Ably documentation.

This repository contains the working code for many of the Ably tutorials.

See https://www.ably.com/tutorials for a complete list of Ably tutorials. The source code for each tutorial exists as a branch in this repo, see the complete list of tutorial branches in this repository.

To find out more Ably and our realtime data delivery platform, visit https://www.ably.com

tutorials's People

Contributors

fliptopbox avatar mattheworiordan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tutorials's Issues

Uncaught ReferenceError in channel-rewind-ablyjs tutorial

Customer raised this issue, which they resolved themselves at the time

Error:
"Uncaught ReferenceError: channelWeather is not defined"

No data is being received either

Resolved:
I have solved it.  the example code is missing a line.  I added "var channelWeather" in at line 45 and it now works

WebRTC-file-transfer tutorial issues

The following tutorial does not work as expected and the following needs to be updated for it to work

  1. Update script tag to latest version of simple peer in index.html

<script src="https://cdnjs.cloudflare.com/ajax/libs/simple-peer/9.11.1/simplepeer.min.js"></script>

as it fails to connect to the STUN servers using what is currently there

<script src="https://cdnjs.cloudflare.com/ajax/libs/simple-peer/9.1.2/simplepeer.min.js"></script>

Failed to construct 'RTCPeerConnection': 'stun:global.stun.twilio.com:3478?transport=udp' is not a valid stun or turn URL.

  1. After point 1 a new error Failed to execute 'send' on 'RTCDataChannel': RTCDataChannel.readyState is not 'open' occurs and so in connection-helper.js the _onSignal method needs to be updated
_onSignal(signal) {
AblyRealtime.publish(`rtc-signal/${this._remoteClient}`, {
user: clientId,
signal: signal,
});
}

Tutorial - Implementing Token Authentication Errors

Following along with this https://ably.com/tutorials/token-authentication and the code doesn't work. I assumed it was something I had copied incorrectly. Got the source from here and tried to run it, same errors.

When entering the username and hitting enter, server.py produces a 500 error and client also produces an error.

This is because the authentication needs to be awaited for the token to be returned in time to return to the client.

Server error:

Traceback (most recent call last): File "/Projects/ably/tutorials/venv/lib/python3.10/site-packages/web/application.py", line 280, in process return self.handle() File "/Projects/ably/tutorials/venv/lib/python3.10/site-packages/web/application.py", line 271, in handle return self._delegate(fn, self.fvars, args) File "/Projects/ably/tutorials/venv/lib/python3.10/site-packages/web/application.py", line 502, in _delegate return handle_class(f) File "/Projects/ably/tutorials/venv/lib/python3.10/site-packages/web/application.py", line 495, in handle_class return tocall(*args) File "/Projects/ably/tutorials/server.py", line 34, in GET return json.dumps(client.auth.create_token_request(token_params).to_dict()) AttributeError: 'coroutine' object has no attribute 'to_dict'

Client error:

09:38:33.437 Ably: Auth.requestToken(): token request signing call returned error; err = [t: Malformed response body from server: Unexpected token '<', "<!DOCTYPE "... is not valid JSON; statusCode=400] r @ ably.min-1.js:24

Environment details:

OSX 14.2.1 
Python 3.10.3
Pip List: 

Package           Version
----------------- ----------
ably              2.0.3
anyio             4.2.0
certifi           2023.11.17
cheroot           10.0.0
exceptiongroup    1.2.0
h11               0.14.0
h2                4.1.0
hpack             4.0.0
httpcore          0.17.3
httpx             0.24.1
hyperframe        6.0.1
idna              3.6
jaraco.functools  4.0.0
methoddispatch    3.0.2
more-itertools    10.2.0
msgpack           1.0.7
pip               22.0.4
pyee              11.1.0
setuptools        58.1.0
sniffio           1.3.0
typing_extensions 4.9.0
web.py            0.62
websockets        10.4

Cannot start the client session - tictactoe tutorial

Doing npm start from the client folder - I get:

> [email protected] start
> webpack-dev-server --hot

(node:1300) [DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
i 「wds」: Project is running at http://localhost:9000/
i 「wds」: webpack output is served from /
i 「wds」: Content not from webpack is served from C:\Users\mini\git\tutorials\server\public
i 「wds」: 404s will fallback to /index.html
node:internal/crypto/hash:71
  this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:71:19)
    at Object.createHash (node:crypto:133:10)
    at module.exports (C:\Users\mini\git\tutorials\client\node_modules\webpack\lib\util\createHash.js:75:53)
    at Compilation.createHash (C:\Users\mini\git\tutorials\client\node_modules\webpack\lib\Compilation.js:1665:16)
    at C:\Users\mini\git\tutorials\client\node_modules\webpack\lib\Compilation.js:933:9
    at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\mini\git\tutorials\client\node_modules\tapable\lib\HookCodeFactory.js:24:12), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook [as _callAsync] (C:\Users\mini\git\tutorials\client\node_modules\tapable\lib\Hook.js:35:21)
    at Compilation.seal (C:\Users\mini\git\tutorials\client\node_modules\webpack\lib\Compilation.js:890:27)
    at C:\Users\mini\git\tutorials\client\node_modules\webpack\lib\Compiler.js:481:17
    at eval (eval at create (C:\Users\mini\git\tutorials\client\node_modules\tapable\lib\HookCodeFactory.js:24:12), <anonymous>:11:1)
    at C:\Users\mini\git\tutorials\client\node_modules\webpack\lib\Compilation.js:758:12
    at C:\Users\mini\git\tutorials\client\node_modules\webpack\lib\Compilation.js:697:9
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11) {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Node.js v18.12.1

Android / Java installation instructions

@piotrekinventica the Java / Android installation instructions have changed unfortunately which needs a small update on your side please for ALL Java & Android demos.

Please see ably/docs#213 and ably/docs#196 once the PR is merged and ensure all changes are reflected.

Also, please confirm if your PRs at https://github.com/ably/docs/pulls can be closed or still need to be merged in. I would like to ensure all work outstanding is merged in in full and we can close this work.

Audit tutorial code for use of current libraries

I updated some tutorials for ably-js 1 a while back, but clearly I missed some -- e.g. https://github.com/ably/tutorials/blob/publish-subscribe-javascript/example.html uses legacy ably-js.

This is a bit of a PITA because you have to change it in the first commit, rebase all the other commits on top of it, and then go to the docs repo and change all the sha references to the new ones ala ably/docs@97a7341 , and then make sure that the website is deployed with the new tutorial text before github garbage collects the old shas, so the links never stop working.

(Idle thought: wouldn't this be easier if the docs repo pointed to tags, e.g. a publish-subscribe-javascript-step1 tag etc. rather than shas, so that we don't need to do docs repo prs every time we do this? cc @mattheworiordan )

Python Snake tutorial Step 4 does not show MQTT "Connected"

Step 4 of the Python Snake MQTT tutorial says to run python code to connect to 'mqtt.ably.io' mqtt broker.

The code

client.loop_start()
   client.connect('mqtt.ably.io', port=8883, keepalive=15)

should trigger the stdout message 'Connected' because the on connect callback prints 'Connected':

def on_connect(client, userdata, flags, rc):
  print('Connected')

But on my system, no 'Connected' message is printed before the python script terminates. I added a time.sleep(5) after client.connect(...) to delay script termination, and 'Connected' now prints, as expected.

Queue tutorials: should we use channel#get rather than channel#consume?

Inspired by intercom conversation just now.

Given we're putting emphasis on the queues as a way for people to use multiple independent workers to each pop messages off to process, rather than for streaming, should we consider having the tutorials use channel#get ('pop one message off') rather than channel#consume ('give me messages as fast as they come')?

(I know my queue-demo used consume(), but that was so we could show off how fast messages got into the queue (and 'processing time' was ~0 as it was just printing them to the console), so the streaming method was fine).

We could even showcase some basic limited concurrency, e.g. something like:

function processItem(item, cb) {
  console.log("Processing item: ", item && String(item.content))
  setTimeout(cb, 5000);
}

function getMessage(channel) {
  channel.get(QUEUE, {}, (err, item) => {
    if(!item) {
      setTimeout(() => getMessage(channel), 1000);
      return;
    }
    processItem(item, (err) => {
      if(err) {
        channel.nack(item);
      } else {
        channel.ack(item);
      }
      // Processing finished, so get another message
      getMessage(channel);
    });
  });
}

const MAX_CONCURRENCY = 5;

amqp.connect(URL, (err, conn) => {
  if (err) bail(err);
  console.log("Connected");

  conn.createChannel((err, ch) => {
    for(let i=0; i<MAX_CONCURRENCY; i++) {
      getMessage(ch);
    }
  });
});

WDYT?

Remove references to options.environment in tutorials

The root of the confusion in https://support.ably.io/a/tickets/105174 is that the push notifications tutorials https://www.ably.io/tutorials/android-push-direct-registration#step4 and https://docs.ably.io/tutorials/android-push-server-registration/ still have references to options.environment = BuildConfig.ABLY_ENV, presumably because we'd told the tutorial author to use the sandbox env. They just shouldn't be there in the final tutorial, they only serve to confuse people. 99% of people don't need to know we even have other clusters

Java/gradle tutorial doesn't work/run

Following this tutorial and trying it locally doesn't seem to work:
https://ably.com/tutorials/token-authentication#tutorial-step-7

Just running gradle shows an error because gradle is not installed (windows 10 and ubuntu).
Running gradlew seems to work, as it downloads a gradle wrapper file, but running gradlew build does nothing and shows no output.

I can't seem to run these tutorials at all.
I've spent a couple of hours now fiddling with gradle, something with which i'm not that familiar with.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.