cch1 / http.async.client Goto Github PK
View Code? Open in Web Editor NEWAsync Http Client - Clojure
Home Page: http://cch1.github.com/http.async.client
Async Http Client - Clojure
Home Page: http://cch1.github.com/http.async.client
https://github.com/neotyk/http.async.client/blob/master/src/clj/http/async/client/headers.clj#L48
https://github.com/neotyk/http.async.client/blob/master/src/clj/http/async/client/headers.clj#L50
https://github.com/neotyk/http.async.client/blob/master/src/clj/http/async/client/headers.clj#L51
I believe these should all throw (UnsupportedOperationException. "Headers are read only.") not just the string.
Alternatively, I believe if you don't provide a method fn, the UnsupportedOperationExceptions are thrown automatically by proxy, though I don't know that for sure being new to proxy and its use.
In the version of Ning's AsyncHttpClient which is currently used in http.async.client there is a bug which causes the 'onComplete' method/callback to be called twice. Later versions reportedly have fixed this issue.
Can http.async.client be updated to depend on a newer version of AsyncHttpClient?
See this exchange for a mention of the bug:
http://groups.google.com/group/asynchttpclient/browse_thread/thread/26466edd0e0dbbd8/3a34784cbb654c1d?lnk=gst&q=oncompleted+called+twice#3a34784cbb654c1d
Was this intentional?
I'm having problems using 0.5.1 with Java 6.
Exception in thread "main" java.lang.UnsupportedClassVersionError: ahc/RequestBuilderWrapper : Unsupported major.minor version 51.0, compiling:(request.clj:15)
Fantastic library. Thanks.
How would I extend to the PROPFIND method.
I am thinking along the lines of
(gen-method :propfind)
(def client (create-client client :auth {:user "user" :password "password"}))
(def body-string "
<D:propfind xmlns:D="DAV:">
<D:prop>
</D:prop>
/D:propfind")
(ignore GITHub's reformatting here - this is a propfind xml query in the body of the request)
(PROPFIND client "http://someurle.com/something" :headers {:content-type "text/xml"} :body body-string)
But I am getting NPE at com.ning.http.client.RequestBuilderBase.allowBody(RequestBuilderBase.java:564)
because the request has got no method associated with it.
Could you help me with this?
Thanks
Robert
If you try to submit a POST request without any :body map or a string, the request will hang and never return.
Provide examples of callbacks usage.
Allow multipart body with PUT and POST.
Multipart is provided as vector argument to :body.
From the defn of ssl-context
:
If [:keystore-file] is empty, will use default keystore.
Passing nil
or ""
for this parameter, or not passing it at all, results in:
java.io.FileNotFoundException
File or resource "" could not be found.
Now it is fn and really is just a hash-map.
Request body of type "String" should be url encoded only if content type has been set to "application/x-www-form-urlencoded"; otherwise, it should be kept untouched.
Here is my code:
(ns grabber.core
(:require [http.async.client :as http])
(:require [http.async.client.request :as request]))
(defn closing [client func]
(fn [& args] (do
(http/close client)
(apply func args)
)))
(defn async-get [url on-compete on-error]
(let [client (http/create-client :follow-redirects true)
request (request/prepare-request :get url)]
(request/execute-request client request
:completed (closing client on-compete)
:error (closing client on-error))))
and REPL:
user=> (use 'grabber.core)
nil
user=> (dotimes [n 50]
(async-get "http://some.url"
#(do % (println (str "done " n))) #(println %2)))
done 5
done 4
done 3
done 6
done 2
done 10
...
And a process gets bigger by 20-30 mb.
(defn my-info []
(with-open [client (http/create-client :proxy {...})]
(let [resp (http/GET client "https://api.github.com/user"
:auth {:user "apa512"
:password "my_password"
:preemptive true})
status (http/status resp)
headers (http/headers resp)
_ (http/await resp)
body (http/string resp)]
(prn headers body))))
Getting authentication error unless I remove the proxy settings.
I am writing a web crawler using the http.async.client but I am having some intermittent issues when parsing the response
In my application there is a get-user-user function similar to this:
(defn get-user-page []
(with-open [client (c/create-client :compression-enabled true)]
(let [response (c/GET client URL)]
(c/await response)
(when-let [err (c/error response)]
(do
(println "failed processing request: " err)
(get-user-page)))
(java.io.StringReader. (c/string response)))))
The problem is that sometimes it raises this exception:
Exception in thread "main" java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.NullPointerException
at clojure.lang.Util.runtimeException(Util.java:165)
at clojure.lang.LazySeq.sval(LazySeq.java:51)
at clojure.lang.LazySeq.seq(LazySeq.java:60)
at clojure.lang.Cons.next(Cons.java:39)
at clojure.lang.RT.next(RT.java:580)
at clojure.core$next.invoke(core.clj:64)
at clojure.core$dorun.invoke(core.clj:2724)
at legendas.core$craw.invoke(core.clj:141)
at legendas.core$_main.invoke(core.clj:146)
at clojure.lang.AFn.applyToHelper(AFn.java:161)
at clojure.lang.AFn.applyTo(AFn.java:151)
at legendas.core.main(Unknown Source)
Caused by: java.util.concurrent.ExecutionException: java.lang.NullPointerException
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)
at java.util.concurrent.FutureTask.get(FutureTask.java:83)
at clojure.core$future_call$reify__5684.deref(core.clj:6054)
at clojure.core$deref.invoke(core.clj:2078)
at legendas.core$cmap$step__1234$fn__1236.invoke(core.clj:123)
at clojure.lang.LazySeq.sval(LazySeq.java:42)
... 10 more
Caused by: java.lang.NullPointerException
at java.io.StringReader.<init>(StringReader.java:33)
at legendas.core$get_user_page.invoke(core.clj:65)
at legendas.core$get_user_and_save.invoke(core.clj:106)
at legendas.core$craw$fn__1243.invoke(core.clj:141)
at legendas.core$cmap$fn__1229$fn__1230.invoke(core.clj:119)
at clojure.core$binding_conveyor_fn$fn__3713.invoke(core.clj:1817)
at clojure.lang.AFn.call(AFn.java:18)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
So I wrapped the (c/string response)
in a try catch block:
(try
(java.io.StringReader. (c/string response))
(catch Exception e
(do
(println "Error\n" (c/string response) (c/status response) response)
(throw e)
(System/exit 0))))
And this was what the println printed:
Error
nil
nil
{:id req-id__35466, :status #<core$promise$reify__5727@4fe4aec2: :pending>, :headers #<core$promise$reify__5727@2e8d6b88: :pending>, :body #<core$promise$reify__5727@468ec598: :pending>, :done #<core$promise$reify__5727@474ea258: true>, :error #<core$promise$reify__5727@7b8463fa: #<TimeoutException java.util.concurrent.TimeoutException: No response received after 60000>>}
It seems that the c/string call is returning nil
and that causing the exception. What I don't get is why it happens since I am already checking for errors before calling c/string. Am I doing something wrong?
Thanks,
Cesar Canassa
Your README advertises v1.0.0 as the latest release (based on Clojars), but it doesn't work.
In https://github.com/cch1/http.async.client/blob/v1.0.0/src/clj/http/async/client.clj#L311 websocket
has a list of options e.g. (:open fn :close fn)
and calls upgrade-handler
, which is expecting unrolled args: https://github.com/cch1/http.async.client/blob/v1.0.0/src/clj/http/async/client/websocket.clj#L101
Hi,
I'm having the same issue as described here https://groups.google.com/forum/?fromgroups=#!topic/httpasyncclient/_z43p1YHH58 but with Clojure 1.4 and http.async.client 0.5.
Any idea?
Thanks,
Julien
I using http.async.client 0.6.0 with clojure 1.7. I get the following error when I execute this code (returns nil):
(with-open [client (http/create-client)] ; Create client
(let [response (http/GET client "http://github.com/neotyk/http.async.client/")] ; request http resource
(-> response
http/await ; wait for response to be received
http/string))) ; read body of response as string
(http/error *1):
core.clj: 7231 clojure.core/realized?
client.clj: 195 http.async.client/failed?
client.clj: 286 http.async.client/error
Problem seems to be with http/string as leaving that call out makes things ok.
Hi. Nice work on this library!
I found a small error in the documentation at http://neotyk.github.com/http.async.client/docs.html#sec-2-6-3
You have
(http/create-client {:follow-redirects true})
but it should be
(http/create-client :follow-redirects true)
You use an a vector of bytes to collect response body, but i found it too bad design.
I have exception when i try to get body of page in Russian lang, i think it is because of troubles with Unicode in your client. Can you use stream of bytes instead vector of bytes, like in clojure.contrib.http.client?
(apply str (map char (:body @(HTTP/GET "http://gettingreal.37signals.com/GR_rus.php"))))
java.lang.IllegalArgumentException: Value out of range for char: -48
Everything I try to request fails. I'm using version 0.5.0, and following the example usage from the docs:
pluck.main=> (with-open [client (http/create-client)] (http/GET client "http://google.com"))
{:id req-id__7105, :url "http://google.com", :raw-url "http://google.com", :status #<core$promise$reify__6153@106305aa: :pending>, :headers #<core$promise$reify__6153@5508e44d: :pending>, :body #<core$promise$reify__6153@3ac4a6d8: :pending>, :done #<core$promise$reify__6153@44a5cd0c: true>, :error #<core$promise$reify__6153@6138f209: #<ConnectException java.net.ConnectException: http://google.com/>>}
pluck.main=> (http/error *1)
#<ConnectException java.net.ConnectException: http://google.com/>
This happens both from a swank server and a lein 2 repl. In both cases, the clj-http client works fine. This is using clojure 1.4.0 on OS X 10.6.8.
Dependency com.ning/async-http-client 1.2.0-SNAPSHOT is unavailable, so the project doesn't currently work from sources.
Hello @cch1,
I bumped into this issue while trying the latest aleph
version (I know I know..it is still alpha
), and I wanted to signal here that I receive the following error (using twitter-api
which is using http.async.client
).
I am open to alpha-alpha
testing ๐
Thanks for your work by the way!
19:57:55.749 [clojure-agent-send-off-pool-1] WARN twitter-streaming-client.impl - exception during streaming action
java.lang.NoSuchMethodError: org.jboss.netty.handler.codec.http.HttpRequest.setHeader(Ljava/lang/String;Ljava/lang/Object;)V
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.construct(NettyAsyncHttpProvider.java:641)
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.buildRequest(NettyAsyncHttpProvider.java:599)
at com.ning.http.client.providers.netty.NettyConnectListener$Builder.build(NettyConnectListener.java:140)
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.doConnect(NettyAsyncHttpProvider.java:1031)
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.execute(NettyAsyncHttpProvider.java:916)
at com.ning.http.client.AsyncHttpClient.executeRequest(AsyncHttpClient.java:512)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28)
at http.async.client.request$execute_request.invokeStatic(request.clj:226)
at http.async.client.request$execute_request.doInvoke(request.clj:187)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invokeStatic(core.clj:650)
at clojure.core$apply.invoke(core.clj:641)
at twitter.request$execute_request_callbacks.invokeStatic(request.clj:41)
at twitter.request$execute_request_callbacks.invoke(request.clj:36)
at twitter.core$http_request.invokeStatic(core.clj:105)
at twitter.core$http_request.invoke(core.clj:87)
at twitter.api.streaming$statuses_filter.invokeStatic(streaming.clj:19)
at twitter.api.streaming$statuses_filter.doInvoke(streaming.clj:19)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invokeStatic(core.clj:650)
at clojure.core$apply.invoke(core.clj:641)
at twitter_streaming_client.impl$create_request_fn$fn__48449.invoke(impl.clj:290)
at twitter_streaming_client.impl$start_twitter_stream_action.invokeStatic(impl.clj:325)
at twitter_streaming_client.impl$start_twitter_stream_action.doInvoke(impl.clj:303)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invokeStatic(core.clj:652)
at clojure.core$binding_conveyor_fn$fn__4676.doInvoke(core.clj:1949)
at clojure.lang.RestFn.applyTo(RestFn.java:146)
at clojure.lang.Agent$Action.doRun(Agent.java:114)
at clojure.lang.Agent$Action.run(Agent.java:163)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
After following both documentation and http.async.client test files, I still cannot get it to work with Clojure 1.2.1. I keep hitting this
Cyclic load dependency: [ /http/async/client/request ]->/http/async/client/util->[ /http/async/client/request ]->/http/async/client->/ovillo/collector/test/core (util.clj:15)
Looks like this issue was resolved in a fork. Can you pull those changes, maybe?
I don't want to await
the response, i want the response to be processed by my callback or put into the channel in CSP style.
Is there any function do that?Thanks.
When trying to extract a response body with the "string" function, it fails if the body is null as follows:
java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.CharSequence
Even if extracting a null body may be an illegal operation, the above exception doesn't make the problem clear for the user.
com.ning/async-http-client is up to version 1.7.21 and the released versino of this library depends on 1.7.10. The transitive dependency to io.netty/netty is for "3.4.4.Final" -that library would be updated to "3.6.6.Final".
We are experiencing strange TCP connection issues and hope that such an update will resolve them.
Provide convenience functions for reading "Content-Type", checking if response is redirect and reading Location header.
It would be nice if the requests could support an array as the value for a parameter, or support a sequence of pairs, so that we could submit more than one value for the same key. Right now, the value of any parameter is (str v), so the only way to sent multiple values for the same key is by converting it to a form-url-encoded string first by hand.
For example:
(client/GET client "http://localhost" :query {:many ["valuea", "valueb", "valuec"]})
Should submit something like:
http://localhost?many=valuea&many=valueb&many=valuec
The clj-apache-http library supports this notation, as well as a sequence of pairs.
Looks like the the org mode rendering of clojure source doesn't handle the leading colon ":" on :description and :dependencies. Is there a workaround? Also the quote characters are inconsistent, with the last 2 pairs using the less common begin and end double quotes, and get escaped like this in HTML:
[org.clojure/clojure-contrib “1.2.0”]
[http.async.client “0.2.0”]])
I have the foll code:
(:require [http.async.client :as c]
[org.danlarkin.json :as j]))
(defn track [s](println %28first %28c/string
%28c/stream-seq :post "http://stream.twitter.com/1/statuses/filter.json"
:body {"track" %28str s)}
:auth {:user u :password p})))))
However the code seems to hang - I thought that "first" would extract and eval the first closure from a lazy-seq and drop the rest of it.
I need this because in case of certain errors, I need to shut down the client - but keep a stream running otherwise. How should I approach this - by constructing my own lazy-seq or something ?
thanks!
Hi!!..I get this error when I run the example:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.NullPointerException (NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:5440)
at clojure.lang.Compiler.eval(Compiler.java:5415)
at clojure.lang.Compiler.eval(Compiler.java:5391)
at clojure.core$eval.invoke(core.clj:2382)
at clojure.main$eval_opt.invoke(main.clj:235)
at clojure.main$initialize.invoke(main.clj:254)
at clojure.main$null_opt.invoke(main.clj:279)
at clojure.main$main.doInvoke(main.clj:354)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:369)
at clojure.lang.AFn.applyToHelper(AFn.java:163)
at clojure.lang.Var.applyTo(Var.java:482)
at clojure.main.main(main.java:37)
Caused by: java.lang.NullPointerException
at user$eval26.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:5424)
... 12 more
what can I do?..thanks
When creating a websocket connection, if you specify :byte, :text, :open and :close handlers as the readme describes, :open gets called twice when the websocket is opened and :close gets called twice when the websocket closes.
Websocket client is accidentally closing when fragmented message is received.
I think it's related to this issue AsyncHttpClient/async-http-client#655
I'm using Leiningen 1.4.0-SNAPSHOPT and running 'lein compile' fails with:
mars:http.async.client matt$ lein compile
Warning: problem requiring hooks: java.lang.NoSuchMethodError:
clojure.lang.RestFn.<init>(I)V (javac.clj:1)
...continuing without hooks completely loaded.
Exception in thread "main" java.lang.IllegalArgumentException:
No matching field found: getCommandLine for
class org.apache.tools.ant.taskdefs.Java (NO_SOURCE_FILE:0)
at clojure.lang.Compiler.eval(Compiler.java:5440)
at clojure.lang.Compiler.eval(Compiler.java:5391)
at clojure.core$eval.invoke(core.clj:2382)
at clojure.main$eval_opt.invoke(main.clj:235)
at clojure.main$initialize.invoke(main.clj:254)
at clojure.main$script_opt.invoke(main.clj:270)
at clojure.main$main.doInvoke(main.clj:354)
at clojure.lang.RestFn.invoke(RestFn.java:458)
at clojure.lang.Var.invoke(Var.java:377)
at clojure.lang.AFn.applyToHelper(AFn.java:174)
at clojure.lang.Var.applyTo(Var.java:482)
at clojure.main.main(main.java:37)
Caused by: java.lang.IllegalArgumentException:
No matching field found: getCommandLine for class
org.apache.tools.ant.taskdefs.Java
at clojure.lang.Reflector.getInstanceField(Reflector.java:245)
at clojure.lang.Reflector.invokeNoArgInstanceMember(Reflector.java:267)
at leiningen.compile$get_readable_form.invoke(compile.clj:116)
at leiningen.compile$eval_in_project.doInvoke(compile.clj:169)
at clojure.lang.RestFn.invoke(RestFn.java:465)
at leiningen.compile$compile.invoke(compile.clj:197)
at clojure.lang.Var.invoke(Var.java:365)
at clojure.lang.AFn.applyToHelper(AFn.java:163)
at clojure.lang.Var.applyTo(Var.java:482)
at clojure.core$apply.invoke(core.clj:542)
at leiningen.core$apply_task.invoke(core.clj:158)
at leiningen.core$_main.doInvoke(core.clj:214)
at clojure.lang.RestFn.applyTo(RestFn.java:138)
at clojure.core$apply.invoke(core.clj:540)
at leiningen.core$_main.invoke(core.clj:219)
at user$eval168.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:5424)
... 11 more
The problem is that
(when option ...
Doesn't distinguish between a nil (meaning don't change the default) and false.
Here is the fix. It also adds the ability to configure a couple more things in the underlying library: asynchronous connection and the executor service
diff --git a/src/clj/http/async/client.clj b/src/clj/http/async/client.clj index ca3ee1e..b4188f3 100644 --- a/src/clj/http/async/client.clj +++ b/src/clj/http/async/client.clj @@ -20,7 +20,8 @@ (:use [http.async.client request headers util] clojure.template) (:import (java.io ByteArrayOutputStream) - (com.ning.http.client AsyncHttpClient AsyncHttpClientConfig$Builder))) + (com.ning.http.client AsyncHttpClient AsyncHttpClientConfig$Builder) + (com.ning.http.client.providers.netty NettyAsyncHttpProviderConfig))) (defn create-client "Creates new Async Http Client. @@ -47,18 +48,26 @@ proxy realm request-timeout - user-agent]}] + user-agent + async-connect + executor-service]}] (AsyncHttpClient. (.build (let [b (AsyncHttpClientConfig$Builder.)] - (when compression-enabled (.setCompressionEnabled b compression-enabled)) + (when (not (nil? compression-enabled)) (.setCompressionEnabled b compression-enabled)) (when connection-timeout (.setConnectionTimeoutInMs b connection-timeout)) - (when follow-redirects (.setFollowRedirects b follow-redirects)) - (when idle-in-pool-timeout (.setIdleConnectionInPoolTimeoutInMs b idle-in-pool-timeout)) - (when keep-alive (.setKeepAlive b keep-alive)) + (when (not (nil? follow-redirects)) (.setFollowRedirects b follow-redirects)) + (when idle-in-pool-timeout (.setConnectionTimeoutInMs b idle-in-pool-timeout)) + (when (not (nil? keep-alive)) (.setAllowPoolingConnection b keep-alive)) (when max-conns-per-host (.setMaximumConnectionsPerHost b max-conns-per-host)) (when max-conns-total (.setMaximumConnectionsTotal b max-conns-total)) (when max-redirects (.setMaximumNumberOfRedirects b max-redirects)) + (when async-connect + (let [provider-config (doto (NettyAsyncHttpProviderConfig.) + (.removeProperty NettyAsyncHttpProviderConfig/USE_BLOCKING_IO) + (.addProperty NettyAsyncHttpProviderConfig/EXECUTE_ASYNC_CONNECT true))] + (.setAsyncHttpClientProviderConfig b provider-config))) + (when executor-service (.setExecutorService b executor-service)) (set-proxy proxy b) (when realm (set-realm realm b))
It was mentioned before that it is not very efficient to create a client per request, do you have any idea of a best approach for this? Maybe a connection pool?
I notice you had an apparent fix for this in issue #4, but it's still happening for me, although inconsistently. It seems to happen after repeated calls to c/GET
that return an empty body.
My hackish workaround was to add this to the :completed callback:
(when-not (realized? (:body resp))
(deliver (:body resp) nil))
Not sure if this "fix" is reliable or whether onCompleted could be called before the body is done being processed.
Now using callback API requires providing all callbacks.
There is a set of default callbacks defined, use callback fns from this map if not provided as argument.
For better performance replace c.c.proxy with c.c.reify
Fequrerequest: When dealing with a source of urls, calling (c/GET client url)
for each url would be convenient. If the client could be configured to the maximum concurrent request to fullfil, the returned promises would just block until the url was requested and taken off the queue.
This should simply be applied to the builder the same way connection-timeout
and request-timeout
are.
Perhaps a newbie issue, but might help others..
I had some issues using the example as the websocket, it was connecting fine, but it did not appear to be handling messages. It looks to me like this example should also include :text
Looking at the code in websocket.clj it does appear to have two distinct methods for handing char vs byte, create-text-listener and create-byte-listener
I just re-used handle-message, added in :text handle-message
eg: (existing)
(defn -main []
(println "Connecting...")
(with-open [client (http/create-client)]
(let [ws (http/websocket client
url
:open on-open
:close on-close
:error on-error
:byte handle-message)]
; this loop-recur is here as a placeholder to keep the process
; from ending, so that the message-handling function will continue to
; print messages to STDOUT until Ctrl-C is pressed
(loop [] (recur)))))
(defn -main []
(println "Connecting...")
(with-open [client (http/create-client)]
(let [ws (http/websocket client
url
:open on-open
:close on-close
:error on-error
:byte handle-message
:text handle-message)]
; this loop-recur is here as a placeholder to keep the process
; from ending, so that the message-handling function will continue to
; print messages to STDOUT until Ctrl-C is pressed
(loop [] (recur)))))
Using latest sources in master, I get the following exception while trying to import client code with "(use '[http.async.client :as http])":
java.lang.ClassNotFoundException: ahc.RequestBuilderWrapper (request.clj:15)
I'm having an issue with packets not being received by the websocket client. Basically the issue is that I'm receiving packets that seem to be dropped by the socket completely, while other packets are going through.
The packets that are dropped are... "large", I guess, in terms of socket. They can contain something like 2000 entries in a JSON file, many - many - k's. I do believe these are compressed, and I can't seem to find any reference to compression in the library code. Disabling compression closes the websocket when a large packet is received.
Note that when I say "large" I mean that, for instance, a very very small packet I'm receiving measures around 11k (11070 characters). I will be receiving much larger than this.
I would like to have the PATCH method implemented. So far, only clj-http implements the PATCH method that I need in my project. But it is bulky.
The changelog (http://neotyk.github.com/http.async.client/changelog.html) shows nothing for the major release 5.0.
Of all the releases that need a changelog, it's the major ones!
For example, the following async request will return an empty response body, which will cause the specified :completed
handler to hang forever:
(execute-request client (prepare-request :get "http://localhost:8123/empty")
:completed (fn [response] @(:body response)))
Under the netty async http provider, this has the additional effect of tying up the run()
loop in AbstractNioSelector
:
https://github.com/netty/netty/blob/netty-3.10.4.Final/src/main/java/org/jboss/netty/channel/socket/nio/AbstractNioSelector.java#L207
which will ultimately cause any calls to close the async client to hang forever.
This code hangs forever:
(let [client (http/create-client :request-timeout 1500
:connection-timeout 1000)
req (http-request/prepare-request
:get "http://nosuch.server/")
resp (http-request/execute-request
client
req
:error (fn [_ _] (throw (Exception. "boom!"))))]
(http/await resp))
It appears that the exception in the :error function eliminates any chance of the underlying promise ever being delivered. It would be nice if http.async.client would protect against bugs in the :error function.
Update documentation to include remove-params-on-redirect (provided by #46).
Provide initial WebSocket support.
Start with just callbacks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.