svanas / PubSub

PubSub is a simple "Hello World" example project, demonstrating how to subscribe to an Ethereum gateway and get notified every time a new block got mined.
MIT License
6 stars 3 forks source link

Hi,guru, git pulled the latest things, but still no-reponse for API Key from both infura and Alchemy. #2

Closed gneowing closed 1 year ago

gneowing commented 1 year ago

Hi,guru, My env: Embarcadero® Delphi 10.4 Version 27.0.38860.1461 (10.4 Update 1) Windows 7 Service Pack 1(Version 6.1, Build 7601 64-bit Edition) SSL DLL is 1.0.2u I did use my API keys from infura and Alchemy. But both no reponse.

2023-05-19 092854 and my exe

svanas commented 1 year ago

my exe: PubSub.zip

Please don't post any attachments, especially no executables. You should never be downloading and executing files over the Internet.

svanas commented 1 year ago

SSL DLL is 1.0.2u I did use my API keys from infura and Alchemy. But both no reponse.

You are compiling a 32-bit target, are you not? Are there no errors whatsoever?

gneowing commented 1 year ago

Yes,32-bit and no errors.

gneowing commented 1 year ago

The compilier output: Checking project dependencies... Building PubSub.dproj (Debug, Win32) brcc32 command line for "PubSub.vrc" c:\delphi10.4update2\bin\cgrc.exe -c65001 PubSub.vrc -foPubSub.res dcc32 command line for "PubSub.dpr" ... [dcc32 Hint] SbpBase16.pas(123): H2443 Inline function 'TUtilities.StringToCharArray' has not been expanded because unit 'System.SysUtils' is not specified in USES list [dcc32 Hint] SbpBase58.pas(182): H2443 Inline function 'TUtilities.StringToCharArray' has not been expanded because unit 'System.SysUtils' is not specified in USES list [dcc32 Hint] SbpBase64.pas(230): H2443 Inline function 'TUtilities.StringToCharArray' has not been expanded because unit 'System.SysUtils' is not specified in USES list [dcc32 Hint] ClpAsn1Objects.pas(4389): H2077 Value assigned to 'TConstructedOctetStream.Read' never used [dcc32 Hint] ClpAsn1Objects.pas(4438): H2077 Value assigned to 'TConstructedOctetStream.ReadByte' never used [dcc32 Hint] ClpAesEngine.pas(520): H2443 Inline function 'TConverters.ReadBytesAsUInt32LE' has not been expanded because unit 'ClpBitConverter' is not specified in USES list [dcc32 Hint] ClpAesEngine.pas(522): H2443 Inline function 'TConverters.ReadBytesAsUInt32LE' has not been expanded because unit 'ClpBitConverter' is not specified in USES list [dcc32 Hint] ClpAesEngine.pas(524): H2443 Inline function 'TConverters.ReadBytesAsUInt32LE' has not been expanded because unit 'ClpBitConverter' is not specified in USES list [dcc32 Hint] ClpAesEngine.pas(526): H2443 Inline function 'TConverters.ReadBytesAsUInt32LE' has not been expanded because unit 'ClpBitConverter' is not specified in USES list [dcc32 Hint] ClpAesEngine.pas(545): H2443 Inline function 'TConverters.ReadBytesAsUInt32LE' has not been expanded because unit 'ClpBitConverter' is not specified in USES list [dcc32 Hint] ClpAesEngine.pas(547): H2443 Inline function 'TConverters.ReadBytesAsUInt32LE' has not been expanded because unit 'ClpBitConverter' is not specified in USES list [dcc32 Hint] ClpAesEngine.pas(549): H2443 Inline function 'TConverters.ReadBytesAsUInt32LE' has not been expanded because unit 'ClpBitConverter' is not specified in USES list [dcc32 Hint] ClpAesEngine.pas(551): H2443 Inline function 'TConverters.ReadBytesAsUInt32LE' has not been expanded because unit 'ClpBitConverter' is not specified in USES list [dcc32 Hint] ClpAesEngine.pas(553): H2443 Inline function 'TConverters.ReadBytesAsUInt32LE' has not been expanded because unit 'ClpBitConverter' is not specified in USES list [dcc32 Hint] ClpAesEngine.pas(555): H2443 Inline function 'TConverters.ReadBytesAsUInt32LE' has not been expanded because unit 'ClpBitConverter' is not specified in USES list [dcc32 Hint] ClpAesEngine.pas(623): H2443 Inline function 'TConverters.ReadBytesAsUInt32LE' has not been expanded because unit 'ClpBitConverter' is not specified in USES list [dcc32 Hint] ClpAesEngine.pas(625): H2443 Inline function 'TConverters.ReadBytesAsUInt32LE' has not been expanded because unit 'ClpBitConverter' is not specified in USES list [dcc32 Hint] ClpAesEngine.pas(627): H2443 Inline function 'TConverters.ReadBytesAsUInt32LE' has not been expanded because unit 'ClpBitConverter' is not specified in USES list [dcc32 Hint] ClpAesEngine.pas(629): H2443 Inline function 'TConverters.ReadBytesAsUInt32LE' has not been expanded because unit 'ClpBitConverter' is not specified in USES list [dcc32 Hint] ClpAesEngine.pas(631): H2443 Inline function 'TConverters.ReadBytesAsUInt32LE' has not been expanded because unit 'ClpBitConverter' is not specified in USES list [dcc32 Hint] ClpAesEngine.pas(633): H2443 Inline function 'TConverters.ReadBytesAsUInt32LE' has not been expanded because unit 'ClpBitConverter' is not specified in USES list [dcc32 Hint] ClpAesEngine.pas(635): H2443 Inline function 'TConverters.ReadBytesAsUInt32LE' has not been expanded because unit 'ClpBitConverter' is not specified in USES list [dcc32 Hint] ClpAesEngine.pas(637): H2443 Inline function 'TConverters.ReadBytesAsUInt32LE' has not been expanded because unit 'ClpBitConverter' is not specified in USES list [dcc32 Hint] ClpAesEngine.pas(758): H2443 Inline function 'TConverters.ReadBytesAsUInt32LE' has not been expanded because unit 'ClpBitConverter' is not specified in USES list [dcc32 Hint] ClpAesEngine.pas(759): H2443 Inline function 'TConverters.ReadBytesAsUInt32LE' has not been expanded because unit 'ClpBitConverter' is not specified in USES list [dcc32 Hint] ClpAesEngine.pas(760): H2443 Inline function 'TConverters.ReadBytesAsUInt32LE' has not been expanded because unit 'ClpBitConverter' is not specified in USES list [dcc32 Hint] ClpAesEngine.pas(761): H2443 Inline function 'TConverters.ReadBytesAsUInt32LE' has not been expanded because unit 'ClpBitConverter' is not specified in USES list [dcc32 Hint] ClpSecureRandom.pas(211): H2077 Value assigned to 'TSecureRandom.Next' never used [dcc32 Hint] ClpSecureRandom.pas(324): H2443 Inline function 'TTimes.NanoTime' has not been expanded because unit 'System.DateUtils' is not specified in USES list [dcc32 Hint] ClpNistNamedCurves.pas(103): H2443 Inline function 'TSecNamedCurves.GetByOid' has not been expanded because unit 'ClpIX9ECParametersHolder' is not specified in USES list [dcc32 Hint] ClpECNamedCurveTable.pas(90): H2443 Inline function 'TSecNamedCurves.GetByName' has not been expanded because unit 'System.SysUtils' is not specified in USES list [dcc32 Hint] ClpECNamedCurveTable.pas(94): H2443 Inline function 'TNistNamedCurves.GetByName' has not been expanded because unit 'System.SysUtils' is not specified in USES list [dcc32 Hint] ClpECNamedCurveTable.pas(99): H2443 Inline function 'TTeleTrusTNamedCurves.GetByName' has not been expanded because unit 'System.SysUtils' is not specified in USES list [dcc32 Hint] ClpECNamedCurveTable.pas(110): H2443 Inline function 'TSecNamedCurves.GetByOid' has not been expanded because unit 'ClpIX9ECParametersHolder' is not specified in USES list [dcc32 Hint] ClpECNamedCurveTable.pas(115): H2443 Inline function 'TTeleTrusTNamedCurves.GetByOid' has not been expanded because unit 'ClpIX9ECParametersHolder' is not specified in USES list [dcc32 Hint] ClpECNamedCurveTable.pas(127): H2443 Inline function 'TSecNamedCurves.GetOid' has not been expanded because unit 'System.SysUtils' is not specified in USES list [dcc32 Hint] ClpECNamedCurveTable.pas(131): H2443 Inline function 'TNistNamedCurves.GetOid' has not been expanded because unit 'System.SysUtils' is not specified in USES list [dcc32 Hint] ClpECNamedCurveTable.pas(136): H2443 Inline function 'TTeleTrusTNamedCurves.GetOid' has not been expanded because unit 'System.SysUtils' is not specified in USES list [dcc32 Hint] ClpECKeyPairGenerator.pas(121): H2443 Inline function 'TCustomNamedCurves.GetByOid' has not been expanded because unit 'ClpIX9ECParametersHolder' is not specified in USES list [dcc32 Warning] web3.rlp.pas(290): W1022 Comparison always evaluates to True [dcc32 Warning] web3.eth.types.pas(350): W1058 Implicit string cast with potential data loss from 'string' to 'ShortString' [dcc32 Warning] web3.eth.types.pas(359): W1058 Implicit string cast with potential data loss from 'string' to 'ShortString' [dcc32 Hint] common.pas(47): H2443 Inline function 'TFile.Create' has not been expanded because unit 'System.Classes' is not specified in USES list [dcc32 Hint] main.pas(244): H2443 Inline function 'Beep' has not been expanded because unit 'Winapi.Windows' is not specified in USES list Success Elapsed time: 00:00:07.7

PieterValentijn commented 1 year ago

As Steven takes all reports seriously, he asked me to test the project using Delphi 10. I have Delphi 10.3 with an older version of the libeay32.dll file. I was able to compile and run the program successfully. I also saw the block numbers being updated. We are not sure what your problem is, but it seems to be more related to your local environment than to the code itself. Therefore, please check your setup, firewall, API keys, etc.

gneowing commented 1 year ago

Thank you PieterValentijn, I studied Steven's code just in spare time, sorry for late reponse. My infura API key should be ok because I have used this API key do other things successfully. Today I closed firewall, still no response.

As my environment , the most suspecious thing is : I used VPN and this VPN acted as global proxy. Is VPN the possible reason to cause this no-response? If it was, how to solve this problem?

PieterValentijn commented 1 year ago

You say no response but does that also mean no error when you run this in the debugger? I have not studied this in full but as we needed to install some commercial components I guess that does something INDY could not. Is this the only example for Delphereum that does not work for you?

gneowing commented 1 year ago

“You say no response but does that also mean no error when you run this in the debugger?” No error in the debugger. And seconds later, the APP give no response. Then I have to kill it after several miniutes. "I guess that does something INDY could not." At least, I have made other APP call FTP components in Indy10.1.5 ( in my delphi10.4.1 ). and this APP worked. "Is this the only example for Delphereum that does not work for you?" Yes, I followed the examples one by one, till now 1st till 10th all workd for me , and this 11th one failed.

gneowing commented 1 year ago

And just now I tried 64-bit target, again no-reponse .

PieterValentijn commented 1 year ago

@Stefan can this example run on ganache? Just to see if the VPN is the problem.

gneowing commented 1 year ago

Oh, sorry, I made a mistake. After building in my physical PC , I always run the PubSub.exe standalone in a virtual PC (WIN 7 + 3G RAM + VPN). Your comment reminded me something. Just now, I re-configured my virtual PC to WIN7+6G RAM + VPN . And run the PubSub.exe in Delphi debug environment, the error occcured. But it is very strange that I have copied the dlls to all the possible used places.

2023-05-22 173024

gneowing commented 1 year ago

oh, need register these two dlls?

PieterValentijn commented 1 year ago

Did you buy the comercial components. if not then that is probably why it does not work.

PieterValentijn commented 1 year ago

And the libeay32.dll must ifcource be the same as your project 32 or 64 bit. I guess thats what is wrong now.

svanas commented 1 year ago

I used VPN and this VPN acted as global proxy.

Please rule out as many external factors as possible. In other words: close your VPN connection and anything else that might interfere with your WebSocket connection, then try again.

svanas commented 1 year ago

can this example run on ganache?

I'm afraid Ganache is JSON-REST only (no PubSub). That is why we need Infura or Alchemy or run our own node.

svanas commented 1 year ago

oh, need register these two dlls?

There is no need to register these two DLLs. They are not ActiveX components.

svanas commented 1 year ago

But it is very strange that I have copied the dlls to all the possible used places.

It is possible for your system to load other DLLs available elsewhere on your system. Please search your system for copies of them, then rename or delete those. You will want your executable to load version 1.0.2u only.

gneowing commented 1 year ago

"Did you buy the comercial components." I found my sgcWebocket is not registered. :(

2023-05-22 215343

svanas commented 1 year ago

I found my sgcWebocket is not registered.

You should be fine. The example should just work with the trail version.

gneowing commented 1 year ago

"It is possible for your system to load other DLLs available elsewhere on your system. Please search your system for copies of them, then rename or delete those. You will want your executable to load version 1.0.2u only." 1) There was an old version dll in <>\Embaracadero\Studio\21.0\bin\subversion, I renamed it; 2) There were two other APPs in my virtual PC contained old version dll, but I do not think they will affect our APP. 3) Other paths have the 1.0.2.u version dll.

2023-05-23 080830 But, still failed.

2023-05-23 081633

Then I unstalled the two other APPs mention in 2). Again failed. 2023-05-23 083234

gneowing commented 1 year ago

I noticed "class DELPHICLASS EIdOSSLCouldNotLoadSSLLibrary;" in c:\Delphi10.4Update2\sgcWebSockets_D10_4\LibD10_4\win32\sgcIdSSLOpenSSL.hpp

So, I guess perhaps I should copy to other places to satisfy sgc things. But alas, failed again. I am confused, where is the right path to place this dll? 2023-05-23 085315

svanas commented 1 year ago

where is the right path to place this dll?

The same directory as where your 32-bit PubSub.exe is

gneowing commented 1 year ago

Hi, gurus, I found that I had copied the 64-bit dll files to the directory to run 32-bit exe. So sorry for having wasted you both lots of time. Now the exception is(With VPN): image

and(Without VPN), so perhaps no VPN ,no etherum for me here ;) image

svanas commented 1 year ago

Now the exception is (With VPN)

socket error 10060 == WSAETIMEDOUT

and (Without VPN)

socket error 10061 == WSAECONNREFUSED

gneowing commented 1 year ago

The latest situation: Alchemy is OK now. And Infura is still no-response. image All I can say is: my Infura API key is no problem according to the former example. Please refer to the following pic that I got balance via my Infura API key. image

gneowing commented 1 year ago

Then I turned to 64bit version. The same situation: Alchemy passed;Infura failed. The new project was named as PubSub64. image And the following pic proved that I did apply 64-bit dlls mentioned before in the project of PubSub64. image

So, let's forget about Infura, just apply Alchemy to continue the 11th example in the git thread of delphereum. The target is 64bit and I used API Key from Alchemy, and still failed, and the exception is : image Also I'll commet this on delphereum thread.

svanas commented 1 year ago

The latest situation: Alchemy is OK now.

Awesome! I am happy to hear you got the WebSocket connection to Alchemy working.

svanas commented 1 year ago

Then I turned to 64bit version.

Let's not complicate the matter and forget about the 64-bit version for a moment. Please compile the 32-bit target and use the 32-bit OpenSLL DLLs only.

PieterValentijn commented 1 year ago

We would like to request your assistance in debugging the issue that prevented you from connecting with Infura. This is an important task that will help us advance our cause and improve our service. Please explain the reason for the connection failure and whether it was due to your error or the server's security settings (such as TLS 1.3). Or was it due to Murphy's law? You know, the one that says anything that can go wrong will go wrong

PieterValentijn commented 1 year ago

ok sry that was AI generated as i dont type like that :-)

gneowing commented 1 year ago

That's all right.:) It's my pleasure and honour to contribute about this . image The error image If press continue: image

Change TLS_12 to TLS_13 image Still the same error. And I found another compile "error" though this error did not effect the build of exe. image

gneowing commented 1 year ago

image image

gneowing commented 1 year ago

The bug was partly cleared. Notice I used VPN. So while infura, proxy should be configured. image

But while alchemy, proxy should not be configured, or , exceptions will occur. image

svanas commented 1 year ago

Fixed in https://github.com/svanas/delphereum/commit/58a688c3ebd28ee36a847d0b1d96cfd35a59a249