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

Can't Run Electrum Daemon on Windows #5511

Open
ztnark opened this issue Jul 14, 2019 · 9 comments
Open

Can't Run Electrum Daemon on Windows #5511

ztnark opened this issue Jul 14, 2019 · 9 comments

Comments

@ztnark
Copy link

ztnark commented Jul 14, 2019

$electrum daemon start

C:\Python36\lib\site-packages\win32\lib\pywintypes.py:2: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp, sys, os
Traceback (most recent call last):
  File "./run_electrum", line 377, in <module>
    pid = os.fork()
AttributeError: module 'os' has no attribute 'fork'```
@bauerj
Copy link
Collaborator

bauerj commented Jul 14, 2019

What exactly are you trying to do? Would running the daemon through WSL work for you?

@Telariust
Copy link

Telariust commented Jul 21, 2019

maybe python36 in 2019? but there are other factors

checked win7x64, cmd as admin

if try run daemon under windows (according to official manual)
C:\1>electrum-3.3.8-portable.exe daemon start
..get back popup-qt

Fatal error detected
Failed to execute script run_electrum

after googled, ./run_electrum - old problem for windows

but use simple fix - run it without start opt
C:\1>electrum-3.3.8-portable.exe daemon
and now in task manager u seen 2proc
dont forget load_wallet
C:\1>electrum-3.3.8-portable.exe daemon load_wallet
after this - rpc full ready!

if would need, add -w [custom_path_to_wallet]

if need close
C:\1>electrum-3.3.8-portable.exe daemon stop

PS:
see also usefull message by @turcol about windows cmd
https://github.com/spesmilo/electrum/issues/2592#issuecomment-484562196

@badhitman
Copy link

maybe python36 in 2019? but there are other factors

checked win7x64, cmd as admin

if try run daemon under windows (according to official manual)
C:\1>electrum-3.3.8-portable.exe daemon start
..get back popup-qt

Fatal error detected
Failed to execute script run_electrum

after googled, ./run_electrum - old problem for windows

but use simple fix - run it without start opt
C:\1>electrum-3.3.8-portable.exe daemon
and now in task manager u seen 2proc
dont forget load_wallet
C:\1>electrum-3.3.8-portable.exe daemon load_wallet
after this - rpc full ready!

if would need, add -w [custom_path_to_wallet]

if need close
C:\1>electrum-3.3.8-portable.exe daemon stop

PS:
see also usefull message by @turcol about windows cmd
https://github.com/spesmilo/electrum/issues/2592#issuecomment-484562196

Electrum daemon fully works in Windows? Daemon starts, but the json rpc api does not function. Am I wrong?

@Telariust
Copy link

Telariust commented Aug 11, 2019

I declare - Electrum daemon fully works in Windows! I am using it now!
(there are just some unobvious details)
(what do you mean by "fully works"?)
(if you mean server electrumX and its server commands, then this is completely different)

Daemon starts, but the json rpc api does not function

json rpc api (after secfix 3.0.5)

  • used rand port
  • used rand password
  • not load_wallet on run (but we can load wallet under rpc, if know right port and pass!)

ok, explain, step-by-step

FAQ, how run Electrum in daemon mode with json rpc api under Windows.

success tested on win7x64, run cmd/.bat as admin

  1. download electrum
    i used electrum-3.3.8-portable.exe
    i dont tested full install ver, but i think - not diff

  2. run it and create wallet
    with seed - better
    if import privkey, some command correlation with seed dont be work(example, getseed)
    if import pub/xpub, some command correlation with privkey dont be work(example, signtransaction)

  3. close it

  4. goto wallet dir, open config, example ./electrum_data/config
    add strings

    "rpcpassword": "myrpcpass",
    "rpcport": 7777,
    "rpcuser": "user",

rpchost not need, all works without it, but u can try 0.0.0.0 or 127.0.0.1
rpcpassword may already be. in base64 form. this is misleading - you DO NOT need to convert your new pwd to base64, and does not affect the basic-auth rpc! just electrum generates a rand pwd from raw bytes and presents them in base64 for convenience.
wrote the new pwd in plaintext and for rpc - too, as it is.
or use default rand pwd as it is, without any decode/encode.

  1. create some .bat files
    create _start-rpc.bat (if want gui)
start electrum-3.3.8-portable.exe
timeout /T 10
start electrum-3.3.8-portable.exe daemon load_wallet

create _start-rpc_as_daemon.bat (if want not gui)

start electrum-3.3.8-portable.exe daemon 
timeout /T 10
start electrum-3.3.8-portable.exe daemon load_wallet

create _stop-rpc.bat (if u want correct close)
start electrum-3.3.8-portable.exe daemon stop

  1. if u want use custom path to wallet, use -w
    start electrum-3.3.8-portable.exe daemon load_wallet -w /path/to/my/wallet/dir

  2. run _start-rpc.bat or _start-rpc_as_daemon.bat
    now in task manager u seen 2proc of electrum, it norm

  3. try connect to rpc, try some commands - all must work

  4. all work on top fork! success tested on
    ElectrumSV-1.2.1-portable
    Electron-Cash-4.0.7-portable
    (but .bat not auto close, because stdout on forks tied to cmd parent proc, but it not big problem)

profit! hoho!

@badhitman
Copy link

ok, explain, step-by-step

FAQ, how run Electrum in daemon mode with json rpc api under Windows.

success tested on win7x64, run cmd/.bat as admin

...

profit! hoho!

I thought I'd check your prescription. tried telnet and VS2019 to read response headers and error description.

win 7 х64 prof / electrum-3.3.8-portable.exe

my conf

"rpcpassword": "user",
"rpcuser": "user",
"rpcport": 7777,

my bat start file

start C:\Users\user\Downloads\electrum-3.3.8-portable.exe daemon --testnet
timeout /T 10
start C:\Users\user\Downloads\electrum-3.3.8-portable.exe daemon --testnet load_wallet -w 'C:\Users\user\Downloads\electrum_data\testnet\wallets\default_wallet'

try for me - telnet
telnet 127.0.0.1 7777

(c) Корпорация Майкрософт (Microsoft Corp.), 2009. Все права защищены.

C:\Users\user>telnet 127.0.0.1 7777
Подключение к 127.0.0.1...Не удалось открыть подключение к этому узлу, на порт 7
777: Сбой подключения

C:\Users\user>

try it in my app .net core 2.2
Подключение не установлено, т.к. конечный компьютер отверг запрос на подключение

   at System.Net.HttpWebRequest.GetResponse() in E:\A\_work\61\s\corefx\src\System.Net.Requests\src\System\Net\HttpWebRequest.cs:line 1014

if you remove the daemon key, the GUI opens correctly and the wallet is loaded. This proves that the file addresses are correct. deamon does not work in any of the options.

@harryqt
Copy link

harryqt commented Mar 2, 2022

@Telariust It worked.. Thank you..

@Telariust
Copy link

-w 'C:\Users\user\Downloads\electrum_data\testnet\wallets\default_wallet'

To be honest, I did not check the performance -w key, but..

  1. CMD in Windows requires the use of double quotes;
  2. Using an escape slash in a path is potentially problematic;
    (typical mistake for users nix2win)
    Therefore, your wallet did not load at all, and as a result
    Try -w "c:/path/wallet"

@de-served
Copy link

de-served commented May 15, 2023

electrum-4.4.3.exe daemon -d
image

This works for me now (little changes from https://electrum.readthedocs.io/en/latest/cmdline.html):

start electrum-4.4.3.exe daemon
[wait until 2 processes raised]
electrum-4.4.3.exe getinfo>2_getinfo.txt
electrum-4.4.3.exe stop>3_stop.txt

Options "-w", "-D" or "--dir", "-v", "daemon -d" did not work at all... more details here: #8429

SomberNight added a commit that referenced this issue May 16, 2023
`-d` is not supported, due to missing os.fork

related: #5511
@SomberNight
Copy link
Member

Note that the daemon can be run:

  • in the background (in "detached" mode):
    $ electrum daemon -d
    • this uses os.fork() and hence is not supported on Windows
  • or in the foreground:
    $ electrum daemon
    • this should work on all platforms (including Windows)

I've added a better error message telling users to try without -d in 68eaa68.

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

No branches or pull requests

8 participants
@bauerj @ztnark @badhitman @de-served @harryqt @SomberNight @Telariust and others