You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey @ZYunf, thanks for reaching out! I just tried to run the Events.java example and in fact it is working here as expected. You need both salt-master and salt-api services to be running with a proper configuration, and then you would change Events.java to match that configuration. For instance if your master configuration has:
Your java code should look like this (please replace hostname with yours):
private static final String SALT_API_URL = "http://hostname:9080";
private static final String USER = "admin";
private static final String PASSWORD = "";
And one more important hint: the ws4py websocket library for Python needs to be installed on the machine where salt-api is running. In openSUSE distributions you can install it to your system via zypper in python3-ws4py, but other distributions should have that package as well under a similar name or you can get it from PyPi (pip install ws4py).
I hope that might help you, otherwise feel free to provide some more details about your setup, for example the configuration you are using for running the API.
@renner Thank you for your prompt reply! I've already installed ws4py,and then I have restarted salt-master and salt-minion.But it seems that ws4py is not working.I run the other modules in Java that work very well.I have got the token.But running Events.java, the following error occurred:
Description of my operating environment
My salt-master is in docker and code runs on the host machine.The port(8000) of the salt-api has been mapped to the host port(8088).so my code like this:
private static final String SALT_API_URL = "http://localhost:8088";
private static final String USER = "saltapi";
private static final String PASSWORD = "saltapi";
I'm not sure if websocket can't be connected due to port problems,or because ws4py doesn't work.Up to now, the error(Handshake error) has not been resolved.I'm looking forward to your help!Thanks!
Activity
renner commentedon Apr 23, 2020
Hey @ZYunf, thanks for reaching out! I just tried to run the
Events.javaexample and in fact it is working here as expected. You need bothsalt-masterandsalt-apiservices to be running with a proper configuration, and then you would changeEvents.javato match that configuration. For instance if your master configuration has:Your java code should look like this (please replace
hostnamewith yours):And one more important hint: the
ws4pywebsocket library for Python needs to be installed on the machine wheresalt-apiis running. In openSUSE distributions you can install it to your system viazypper in python3-ws4py, but other distributions should have that package as well under a similar name or you can get it from PyPi (pip install ws4py).I hope that might help you, otherwise feel free to provide some more details about your setup, for example the configuration you are using for running the API.
ZYunf commentedon Apr 24, 2020
@renner Thank you for your prompt reply! I've already installed ws4py,and then I have restarted
salt-masterandsalt-minion.But it seems thatws4pyis not working.I run the other modules inJavathat work very well.I have got the token.But runningEvents.java, the following error occurred:ws4pyandcherrypyhas been installed like this:The following is my configuration file in
/etc/salt/master.d/filename:api.config
Filename:auth.config
Description of my operating environment
My salt-master is in docker and code runs on the host machine.The port(
8000) of the salt-api has been mapped to the host port(8088).so my code like this:I'm not sure if
websocketcan't be connected due to port problems,or becausews4pydoesn't work.Up to now, the error(Handshake error) has not been resolved.I'm looking forward to your help!Thanks!NemanyaM commentedon Mar 29, 2021
@ZYunf If you make ws4py set up correctly, and try to obtain
AuthModule.PAMwhen obtaining a login token, shouldn't give you aHandshake error.