Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration of adapter with dev-server #107

Open
formifan2002 opened this issue Feb 6, 2023 · 0 comments
Open

Configuration of adapter with dev-server #107

formifan2002 opened this issue Feb 6, 2023 · 0 comments

Comments

@formifan2002
Copy link

formifan2002 commented Feb 6, 2023

When trying to open the instance configuration of an adapter with "adapter-react-v5" in the development server (dev-server), the socket.io connection fails. Consequence: the configuration dialog does not open. You can see this, if you e.g. open the development tool in Chrome (see screenshot at the end) and follow up the error messages returned by the socket.io.js of the ioBroker.admin (path: \dev-server\default\node_modules\iobroker.admin\www\lib\js\socket.io.js).

This behaviour only occurs, with the adapter, that is watched by the development server ! You can reproduce this, if you take a working production adapter like the "[ioBroker.gigaset-element]" (https://github.com/matthsc/ioBroker.gigaset-elements). The adapter is based on adapter-react-v5. If you install the adapter in the dev-server environement with the normal procedure everything works fine. As soon as you download the source and install a dev-server with this, the configuration dialog will not open.

The reason for the described error is the path, that is handed over to the socket.io.

I figured out, that the root cause is in Connection.js of adapter-react-v5 in line 244 (" var pos = path.lastIndexOf('/');"). When using the dev-sever, the path variable at this point of time is "/adapter/ADAPTERNAME/index_m.html". In the following 3 code lines the variable is reduced to "/adapter/ADAPTERNAME/" and is finally handed over to the socket.io interface. Here in the "socket.io.js" in the code line "socket = new WebSocket(u);" the url (u) includes the path. If you remove the the path, everything works fine and the adapter configuration works perfectly.

As a workaround I added the following code directly before the creation of WebSocket in the socket.io.js. With this everything works fine:

        if (options && options.path) {
            u=u.replace(options.path.replace('/socket.io',''),'')
        }

Below the screen shot of the Chrome development tool:

SocketIoError

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant