Help needed for some basic websocket binding

I want to implement a new binding for the yio remote (see

therefore I started today with the implementing of a simple websocket code

The protocol is stated here:

try {
            URI uri;
            uri = new URI("ws://" + config.yiodockhostip + ":946");

            try {
            } catch (Exception e) {
                logger.warn("Web socket start failed", e);
                // throw new IOException("Web socket start failed");

            try {
                YIOremoteBindingConstants.yiodockwebSocketClientSession = YIOremoteBindingConstants.yiodockwebSocketClient
                        .connect(this, uri, new ClientUpgradeRequest()).get();
            } catch (Exception e) {
                logger.warn("Web socket connect failed " + uri.toString(), e);
                // throw new IOException("Web socket start failed");

        } catch (URISyntaxException e) {
            logger.debug("Initialize web socket failed", e);
        if (YIOremoteBindingConstants.yiodockwebSocketClientSession != null) {
        } else {

but it always can’t connect even I checked the URI is correct any suggestion what I am doing wrong?

Difficult to say as this is only a small part of the code. However it looks like your using a websocket client field that is a static field in your constants class, and assign to another static field in that class. That might not be a cause to the specific issue here, but if I’m correct, its certainly an anti-pattern. Look at other bindings how they create a websocket connection. For example look at the deconz binding.

And when asking for help debugging a problem with a library, it’s always a good idea to provide a link to the library code.

Otherwise people have to guess at what it does instead of knowing what it does.

1 Like


These are not constants and don’t belong in a constants file.

// List of all used global variables
    public static final WebSocketClient yiodockwebSocketClient = new WebSocketClient();
    public static @Nullable Session yiodockwebSocketClientSession = null;

This help me Thanks

Wouldent you just get the remote to control openhab using the rest api

Sample config.json Integration entry :

        "log": "debug",
                "url": "",
                "polling_interval": 2000,
                "friendly_name": "RIC's OpenHab",
                "id": "openhab"

Because the dock can send/receive IR commands for other rules…