stock-tracker icon indicating copy to clipboard operation
stock-tracker copied to clipboard

can't fetch data from CHINA stock api

Open lvscar opened this issue 11 months ago • 5 comments

While US stock api work well, I can't fetch data from CHINA stock api. The error message in my Message buffer is :

gnutls.el: (err=[-54] Error in the pull function.) boot: (:priority NORMAL:%DUMBFW :hostname api.money.126.net :loglevel 0 :min-prime-bits nil :trustfiles (/etc/ssl/cert.pem) :crlfiles nil :keylist nil :verify-flags nil :verify-error nil :pass nil :flags nil :callbacks nil)

I have opened ^toggle-debug-on-error , bug still can't see more debug information.

My environment is:

  • OS: MacOS 14.7.4
  • Emacs 30.1

I have written a simple function to test url-retrieve-synchronously which you used in stock-tracker.el in my environment, found it download the HTML file of https://money.163.com/stock without problem.

` (defun download-data-from-url (url) "Download data from the specified URL and return the response body." (let ((url-buffer (url-retrieve-synchronously url))) (if url-buffer (with-current-buffer url-buffer ;; Skip the HTTP headers (goto-char (point-min)) (re-search-forward "^$") ; Find the end of the headers (delete-region (point) (point-min)) ; Delete headers (buffer-string)) ; Return the response body as a string (error "Failed to retrieve data from URL: %s" url))))

(download-data-from-url "https://money.163.com/stock/") ;; no problem `

lvscar avatar Apr 14 '25 06:04 lvscar

I tested again in a different environment (Ubuntu 24.04.1 LTS + GNU Emacs 29.3 ) , still got this error: gnutls.el: (err=[-54] Error in the pull function.) boot: (:priority NORMAL:%DUMBFW :hostname api.money.126.net :loglevel 0 :min-prime-bits nil :trustfiles (/etc/ssl/certs/ca-certificates.crt) :crlfiles nil :keylist nil :verify-flags nil :verify-error nil :callbacks nil)

lvscar avatar Apr 14 '25 09:04 lvscar

after (setq gnutls-log-level 2) I can see more debug information:

gnutls.c: [1] (Emacs) connecting to host: api.money.126.net
gnutls.c: [1] (Emacs) allocating credentials
gnutls.c: [2] (Emacs) allocating x509 credentials
gnutls.c: [2] (Emacs) using default verification flags
gnutls.c: [1] (Emacs) setting the trustfile:  /etc/ssl/certs/ca-certificates.crt
gnutls.c: [1] (Emacs) gnutls callbacks
gnutls.c: [1] (Emacs) gnutls_init
gnutls.c: [1] (Emacs) got non-default priority string: NORMAL:%DUMBFW
gnutls.c: [1] (Emacs) setting the priority string
gnutls.c: [2] added 3 protocols, 29 ciphersuites, 19 sig algos and 10 groups into priority list

gnutls.c: [2] Keeping ciphersuite 13.02 (GNUTLS_AES_256_GCM_SHA384)

gnutls.c: [2] Keeping ciphersuite 13.03 (GNUTLS_CHACHA20_POLY1305_SHA256)

gnutls.c: [2] Keeping ciphersuite 13.01 (GNUTLS_AES_128_GCM_SHA256)

gnutls.c: [2] Keeping ciphersuite 13.04 (GNUTLS_AES_128_CCM_SHA256)

gnutls.c: [2] Keeping ciphersuite c0.2c (GNUTLS_ECDHE_ECDSA_AES_256_GCM_SHA384)

gnutls.c: [2] Keeping ciphersuite cc.a9 (GNUTLS_ECDHE_ECDSA_CHACHA20_POLY1305)

gnutls.c: [2] Keeping ciphersuite c0.ad (GNUTLS_ECDHE_ECDSA_AES_256_CCM)

gnutls.c: [2] Keeping ciphersuite c0.0a (GNUTLS_ECDHE_ECDSA_AES_256_CBC_SHA1)

gnutls.c: [2] Keeping ciphersuite c0.2b (GNUTLS_ECDHE_ECDSA_AES_128_GCM_SHA256)

gnutls.c: [2] Keeping ciphersuite c0.ac (GNUTLS_ECDHE_ECDSA_AES_128_CCM)

gnutls.c: [2] Keeping ciphersuite c0.09 (GNUTLS_ECDHE_ECDSA_AES_128_CBC_SHA1)

gnutls.c: [2] Keeping ciphersuite c0.30 (GNUTLS_ECDHE_RSA_AES_256_GCM_SHA384)

gnutls.c: [2] Keeping ciphersuite cc.a8 (GNUTLS_ECDHE_RSA_CHACHA20_POLY1305)

gnutls.c: [2] Keeping ciphersuite c0.14 (GNUTLS_ECDHE_RSA_AES_256_CBC_SHA1)

gnutls.c: [2] Keeping ciphersuite c0.2f (GNUTLS_ECDHE_RSA_AES_128_GCM_SHA256)

gnutls.c: [2] Keeping ciphersuite c0.13 (GNUTLS_ECDHE_RSA_AES_128_CBC_SHA1)

gnutls.c: [2] Keeping ciphersuite 00.9d (GNUTLS_RSA_AES_256_GCM_SHA384)

gnutls.c: [2] Keeping ciphersuite c0.9d (GNUTLS_RSA_AES_256_CCM)

gnutls.c: [2] Keeping ciphersuite 00.35 (GNUTLS_RSA_AES_256_CBC_SHA1)

gnutls.c: [2] Keeping ciphersuite 00.9c (GNUTLS_RSA_AES_128_GCM_SHA256)

gnutls.c: [2] Keeping ciphersuite c0.9c (GNUTLS_RSA_AES_128_CCM)

gnutls.c: [2] Keeping ciphersuite 00.2f (GNUTLS_RSA_AES_128_CBC_SHA1)

gnutls.c: [2] Keeping ciphersuite 00.9f (GNUTLS_DHE_RSA_AES_256_GCM_SHA384)

gnutls.c: [2] Keeping ciphersuite cc.aa (GNUTLS_DHE_RSA_CHACHA20_POLY1305)

gnutls.c: [2] Keeping ciphersuite c0.9f (GNUTLS_DHE_RSA_AES_256_CCM)

gnutls.c: [2] Keeping ciphersuite 00.39 (GNUTLS_DHE_RSA_AES_256_CBC_SHA1)

gnutls.c: [2] Keeping ciphersuite 00.9e (GNUTLS_DHE_RSA_AES_128_GCM_SHA256)

gnutls.c: [2] Keeping ciphersuite c0.9e (GNUTLS_DHE_RSA_AES_128_CCM)

gnutls.c: [2] Keeping ciphersuite 00.33 (GNUTLS_DHE_RSA_AES_128_CBC_SHA1)

gnutls.c: [2] Advertizing version 3.4

gnutls.c: [2] Advertizing version 3.3

gnutls.c: [2] HSK[0x55d181d03810]: sent server name: 'api.money.126.net'

gnutls.c: [1] (Emacs) non-fatal error: Resource temporarily unavailable, try again. [9 times]
gnutls.c: [1] (Emacs) fatal error: Error in the pull function.
gnutls.el: (err=[-54] Error in the pull function.) boot: (:priority NORMAL:%DUMBFW :hostname api.money.126.net :loglevel 2 :min-prime-bits nil :trustfiles (/etc/ssl/certs/ca-certificates.crt) :crlfiles nil :keylist nil :verify-flags nil :verify-error nil :callbacks nil)
gnutls.c: [1] (Emacs) fatal error: The specified session has been invalidated for some reason. [2 times]

lvscar avatar Apr 14 '25 09:04 lvscar

the api for fetching chinese stock prices is down for a long time. currently I can't find free api for chinese market, so now only us stock works.. sorry for that.

beacoder avatar Apr 14 '25 09:04 beacoder

I have mentioned this in stock-tracker.el already.

;; disable test for CHN stocks due to API not working ;; (cl-assert (stock-tracker--request-synchronously "0600000" (make-stock-tracker--chn-symbol))) ;; (cl-assert (stock-tracker--request-synchronously "1002024" (make-stock-tracker--chn-symbol)))

beacoder avatar Apr 14 '25 09:04 beacoder

Thanks for your reply. The code base is still valuable.

lvscar avatar Apr 14 '25 09:04 lvscar