dmcallejo / ASFBot

Control your ArchiSteamFarm with Telegram
GNU General Public License v3.0
43 stars 10 forks source link

ASFBot - CRITICAL - Couldn't communicate with ASF. Host: 'asf' Port: '1242' #11

Closed nath67 closed 9 months ago

nath67 commented 2 years ago

Hello,

I'm getting the same error as this issue : https://github.com/dmcallejo/ASFBot/issues/2

asfbot | 2022-01-06 19:24:56,357 - ASFBot - INFO - Starting up bot... asfbot | 2022-01-06 19:24:56,366 - ASFBot - CRITICAL - Couldn't communicate with ASF. Host: 'asf' Port: '1242' asfbot | HTTPConnectionPool(host='asf', port=1242): Max retries exceeded with url: /Api/ASF (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9d8e7f55a0>: Failed to establish a new connection: [Errno 111] Connection refused'))

dmcallejo commented 2 years ago

Hello, current version is running fine with latest ASF. Tell me more about your setup, how are you running ASF, and ASFBot. It looks like maybe you're running through a compose file? What's the name of the ASF service? Also, have you enabled IPC in the ASF configuration?

Cheers

nath67 commented 2 years ago

I didn't get how to make the ASF.json These are my files in my config folder: ASF.db Nathan.bin Nathan.db Nathan.json

This is my docker-compose :

version: '3.2'
services:
  asf:
    image: justarchi/archisteamfarm
    container_name: asf
    hostname: asf
    restart: unless-stopped
    environment:
      - ASF_ARGS=--server
    ports:
      - 1242:1242
    volumes:
      - ./config:/app/config
  asfbot:
    image: dmcallejo/asfbot
    container_name: asfbot
    hostname: asfbot
    restart: unless-stopped
    command: --host asf
    environment:
      - TELEGRAM_BOT_TOKEN=XXX
      - TELEGRAM_USER_ALIAS=XXX
dmcallejo commented 2 years ago

You can still enable IPC via ASF's WebUI. You should be able to access it in http://localhost:1242

ASF.json file is a simple JSON file. I think you can generate your own file here: https://justarchinet.github.io/ASF-WebConfigGenerator/#/ There you can also enable IPC

nath67 commented 2 years ago

I get this error when trying to access the webui (same problem on web browser, no response): nspaeter@nas:~$ curl localhost:1242 curl: (56) Recv failure: Connection reset by peer

I generated the ASF and it looks like that :

{
  "s_SteamOwnerID": "XXX",
  "IPC": true
}
nath67 commented 2 years ago

But still get this error because WebUI is not accessible

dmcallejo commented 2 years ago

Then I think there's an issue with your ASF instance or your docker networks.

Are you sure ASF is starting correctly?

nath67 commented 2 years ago

Yes an issue with parameters --server

**asf       | 2022-01-06 21:34:11|ArchiSteamFarm-17|WARN|ASF|ParseArgs() Unknown command-line argument: --server**
asf       | 2022-01-06 21:34:11|ArchiSteamFarm-17|INFO|ASF|InitCore() ArchiSteamFarm V5.2.1.5 (linux-x64/XXX | .NET 6.0.1; debian.11-x64; Linux 5.10.0-10-amd64 #1 SMP Debian 5.10.84-1 (2021-12-08))
asf       | 2022-01-06 21:34:11|ArchiSteamFarm-17|INFO|ASF|InitCore() Copyright © 2015-2022 JustArchiNET
asf       | 2022-01-06 21:34:13|ArchiSteamFarm-17|INFO|ASF|InitPlugins() Initializing Plugins...
asf       | 2022-01-06 21:34:13|ArchiSteamFarm-17|INFO|ASF|InitPlugins() Loading SteamTokenDumperPlugin V5.2.1.5...
asf       | 2022-01-06 21:34:13|ArchiSteamFarm-17|INFO|ASF|InitPlugins() SteamTokenDumperPlugin has been loaded successfully!
asf       | 2022-01-06 21:34:13|ArchiSteamFarm-17|INFO|ASF|UpdateAndRestart() ASF will automatically check for new versions every 1 day.
asf       | 2022-01-06 21:34:13|ArchiSteamFarm-17|INFO|ASF|Update() Checking for new version...
asf       | 2022-01-06 21:34:15|ArchiSteamFarm-17|INFO|ASF|Update() Local version: 5.2.1.5 | Remote version: 5.2.1.5
asf       | 2022-01-06 21:34:15|ArchiSteamFarm-17|INFO|ASF|OnASFInit() SteamTokenDumperPlugin is currently disabled according to your configuration. If you'd like to help SteamDB in data submission, please check out our wiki.
asf       | 2022-01-06 21:34:15|ArchiSteamFarm-17|INFO|ASF|Start() Starting IPC server...
asf       | 2022-01-06 21:34:17|ArchiSteamFarm-17|INFO|ASF|Start() IPC server ready!
asf       | 2022-01-06 21:34:17|ArchiSteamFarm-17|INFO|Nathan|Start() Starting...
asf       | 2022-01-06 21:34:17|ArchiSteamFarm-17|INFO|Nathan|Connect() Connecting...
asf       | 2022-01-06 21:34:18|ArchiSteamFarm-17|INFO|Nathan|OnConnected() Connected to Steam!
asf       | 2022-01-06 21:34:18|ArchiSteamFarm-17|INFO|Nathan|OnConnected() Logging in...
asf       | 2022-01-06 21:34:18|ArchiSteamFarm-17|WARN|ASF|Load() Your Steam password for 'XXX' seems to be weak. Consider choosing a stronger one for increased security. Details: Add another word or two.  Uncommon words are better.
asf       | 2022-01-06 21:34:19|ArchiSteamFarm-17|INFO|Nathan|OnLoggedOn() Successfully logged on as XXX.
asf       | 2022-01-06 21:34:20|ArchiSteamFarm-17|INFO|Nathan|Init() Logging in to ISteamUserAuth...
asf       | 2022-01-06 21:34:20|ArchiSteamFarm-17|INFO|Nathan|Init() Success!
asf       | 2022-01-06 21:34:22|ArchiSteamFarm-17|INFO|Nathan|IsAnythingToFarm() Checking first badge page...
asf       | 2022-01-06 21:34:24|ArchiSteamFarm-17|INFO|Nathan|Farm() We have a total of 105 games (337 cards) left to farm (~1 week, 11 hours, 47 minutes remaining)...
asf       | 2022-01-06 21:34:24|ArchiSteamFarm-17|INFO|Nathan|Farm() Chosen farming algorithm: Complex
asf       | 2022-01-06 21:34:25|ArchiSteamFarm-17|INFO|Nathan|FarmSolo() Now farming: 104900 (ORION: Prelude)
asf       | 2022-01-06 21:34:26|ArchiSteamFarm-17|INFO|Nathan|ShouldFarm() Farming status for 104900 (ORION: Prelude): 1 cards remaining
asf       | 2022-01-06 21:34:26|ArchiSteamFarm-17|INFO|Nathan|FarmCards() Still farming: 104900 (ORION: Prelude)
dmcallejo commented 2 years ago

Yes, I checked my logs too and apparently the --server flag has been deprecated.

Your version and logs are just the same as mine, and IPC is started and running. Since you are not able to reach the container from the outside or other containers I believe there's an issue with your docker networks or docker engine.

I suggest you to try some other image to try and reach it from the outside (nginx for example), restart the docker engine, or reboot your machine.

It doesn't look like a bot problem so I'm closing the issue.

nath67 commented 2 years ago

Could you provide me your ASF.json please? I think that my ICPPrefixes are wrong because from the inside of the container ASF, I can curl the URL but not from my host. The problem is there.

I have other containers running (Jellyfin, Caddy, etc) and it's working fine.

This is my ASF.json

 {
  "SteamOwnerID": XXX,
  "IPCPrefixes": [
    "http://*:1242/"
  ]
}

When I launch the container, it removes this line ""IPC": true," because its the default value but IPC starts anyways.

dmcallejo commented 2 years ago

Mmmmh, you're probably right, maybe it's a prefix issue. Try this: Create a file in the ASF config directory, name it IPC.config

{
    "Kestrel": {
        "Endpoints": {
            "IPv4-http": {
                "Url": "http://0.0.0.0:1242"
            }
        },
        "PathBase": "/"
    }
}
dmcallejo commented 2 years ago

Okay, now it works, I can access the WebUI and the bot can access asf:1242 but the bot is getting this error : 403 Client Error: Forbidden for url: http://asf:1242/Api/ASF

Because of this : https://github.com/JustArchiNET/ArchiSteamFarm/wiki/IPC#why-am-i-getting-403-forbidden-error-when-not-using-ipcpassword

Well, that's also new. I should address these things in the readme.

Have to define "IPCPassword" but "null" value is not working.

You have to define something as password. Not ideal but anyway, remember to specify it in the bot with the environment variable ASF_IPC_PASSWORD

nath67 commented 2 years ago

Okay, now it works, I can access the WebUI and the bot can access asf:1242 but the bot is getting this error : 403 Client Error: Forbidden for url: http://asf:1242/Api/ASF Because of this : https://github.com/JustArchiNET/ArchiSteamFarm/wiki/IPC#why-am-i-getting-403-forbidden-error-when-not-using-ipcpassword

Well, that's also new. I should address these things in the readme.

Have to define "IPCPassword" but "null" value is not working.

You have to define something as password. Not ideal but anyway, remember to specify it in the bot with the environment variable ASF_IPC_PASSWORD

Yes, I did this, now its working perfectly. I typed this : "IPCPassword:": "XXX" Instead of this : "IPCPassword": "XXX"

I'm tired lmao.

Thank you very much for your time, I hope my problem will help other people.

nath67 commented 2 years ago

Working minimal configuration :

ASF.json

{
  "IPCPassword": "XXX",
  "SteamOwnerID": XXX,
  "IPCPrefixes": [
    "http://*:1242/"
  ]
}

IPC.config

{
  "Kestrel": {
    "Endpoints": {
      "IPv4-http": {
        "Url": "http://0.0.0.0:1242"
      }
    },
    "PathBase": "/"
  }
}
dmcallejo commented 2 years ago

You're welcome! Thank you for pointing out those new configuration requirements. I'll add them to the Readme!

Cheers!