Repository: Chia-Network/chia-blockchain

Issue:
[Bug] Error when Viewing Pool Login Link
### What happened?

The original error was that there was no current difficulty. Because of that I wasn't receiving any partials and whenever I try to view the Pool Login Link I get the following error:

```
TypeError: unsupported operand type(s) for /: 'int' and 'NoneType'
```

![Chia Error](https://user-images.githubusercontent.com/36769780/158420095-5b9df11c-9cf8-42c2-af18-15b660d436f3.png)

Same error happens in both CLI and GUI.

### Version

1.3.0

### What platform are you using?

Linux

### What ui mode are you using?

CLI

### Relevant log output

```shell
farmer chia.rpc.util              : WARNING  Error while handling message: Traceback (most recent call last):
  File "/home/eamb/chia-blockchain/chia/rpc/util.py", line 16, in inner
    res_object = await f(request_data)
  File "/home/eamb/chia-blockchain/chia/rpc/farmer_rpc_api.py", line 130, in get_pool_login_link
    login_link: Optional[str] = await self.service.generate_login_link(launcher_id)
  File "/home/eamb/chia-blockchain/chia/farmer/farmer.py", line 625, in generate_login_link
    authentication_token = get_current_authentication_token(authentication_token_timeout)
  File "/home/eamb/chia-blockchain/chia/protocols/pool_protocol.py", line 170, in get_current_authentication_token
    return uint64(int(int(time.time() / 60) / timeout))
TypeError: unsupported operand type(s) for /: 'int' and 'NoneType'
```



Discussion:
I tried switching to self pool, it looks like it worked, but now when I try to re-join the pool I receive another error:

```
wallet chia.rpc.rpc_server        : WARNING  Error while handling message: Traceback (most recent call last):
  File "/home/eamb/chia-blockchain/chia/rpc/rpc_server.py", line 215, in safe_handle
    response = await self.ws_api(message)
  File "/home/eamb/chia-blockchain/chia/rpc/rpc_server.py", line 206, in ws_api
    return await f(data)
  File "/home/eamb/chia-blockchain/chia/rpc/wallet_rpc_api.py", line 1346, in pw_join_pool
    total_fee, tx, fee_tx = await wallet.join_pool(new_target_state, fee)
  File "/home/eamb/chia-blockchain/chia/pools/pool_wallet.py", line 704, in join_pool
    raise ValueError(f"Cannot join a pool while waiting for target state: {self.target_state}")
ValueError: Cannot join a pool while waiting for target state: {'owner_pubkey': '0x8216c79a8fb2615619c7bedba6b2864796f05b73f6d0922daa8cc33c13e4348cc45831efe8a963e5e80cbc9ceb87f67e',
 'pool_url': None,
 'relative_lock_height': 0,
 'state': 1,
 'target_puzzle_hash': '0xd47d8864e3120e59e0dcbe2c79d8839ed6bd322d402902d1c4add283fc96b6ce',
 'version': 1}
```

![Chia Error 2](https://user-images.githubusercontent.com/36769780/158574178-50d54286-e0ba-4e87-ad0b-8eeb0792f08d.png)

The error persists even after a lot of blocks being added.
Guys, I just found out that the problem was with my mesh system configuration that was blocking the connection to the pool. Fixing the configuration solved the issue.
I think its more a question of better error handling due to not having the _**authentication_token_timeout**_ from the pool (and also not having the _**Difficulty**_).

Thank you!
Hi, I have exactly the same problem. How did  you solve that? What do you mean with mesh configuration? STAI is working fine with same plots and same configuration for me.
hi! how did you solve it

Resolving patch:
diff --git a/chia/farmer/farmer.py b/chia/farmer/farmer.py
--- a/chia/farmer/farmer.py
+++ b/chia/farmer/farmer.py
@@ -629,6 +629,13 @@ async def generate_login_link(self, launcher_id: bytes32) -> Optional[str]:
                     self.log.error(f"Could not find authentication sk for {pool_config.p2_singleton_puzzle_hash}")
                     continue
                 authentication_token_timeout = pool_state["authentication_token_timeout"]
+                if authentication_token_timeout is None:
+                    self.log.error(
+                        f"No pool specific authentication_token_timeout has been set for"
+                        f"{pool_config.p2_singleton_puzzle_hash}, check communication with the pool."
+                    )
+                    return None
+
                 authentication_token = get_current_authentication_token(authentication_token_timeout)
                 message: bytes32 = std_hash(
                     AuthenticationPayload(


Test patch: