问题标签 [spray-client]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
587 浏览

scala - spray-testkit:找不到参数 ta 的隐含值:

第一次喷用户接近扯掉头发。

导入 org.scalatest.FlatSpec 导入 spray.testkit.ScalatestRouteTest

以及精彩的编译错误信息:

谁能指出我正确的方向?从示例中复制粘贴spray-testkit似乎失败了。

0 投票
1 回答
149 浏览

scala - Akka IO 和 TestActorRef

如果我需要通过 spray-can 编写涉及 HTTP 请求的集成测试,我如何确保 spray-can 正在使用 CallingThreadDispatcher?

目前以下演员将打印None

如何确保请求在与测试相同的线程上执行(导致同步请求)?

0 投票
2 回答
884 浏览

scala - 喷雾客户端 sendReceive 抛出 SSLHandshakeException

我正在尝试使用 https 使喷雾客户端连接到受限的 rest api。问题是远程服务器的证书未注册为受信任,然后简单的 Get() 连接被 SSLHandshakeException 拒绝,我很难找到有关如何使其工作的任何信息。这可以在我的本地机器上以某种方式工作,而无需更改某些内容。

我找到了有关如何将证书放入 jvm 信任库的教程,但是由于我使用的是 dokku/docker,AFAIK jvm 实例是特定于容器的(或者?)。即使将来我可能会在不同的机器上重新部署应用程序,我希望在应用程序中定义它,而不是每次都设置 jvm。

这是我第一次以编程方式面对 SSL,所以我可能会对它的工作方式做出错误的假设。你能帮我吗?

0 投票
1 回答
1077 浏览

scala - 非法响应标头 Scala Spray 流水线

当我尝试从 Scala Spray 传输请求时出现以下错误

这是我构建请求的地方:

我真的不太了解Access Control Allow Origin。我是否需要在此请求中添加某种标头才能使其正常工作?

0 投票
2 回答
547 浏览

scala - 发布没有键值对的 JSON 消息

这是我尝试发布到 Web 服务的示例:

Content-Type: application/json "0100000001d238c42ec059b8c7747cd51debb4310108f6279d14957472822cf061a660828b000000006b483045022100d326257244e8cb86889509cf5b4717edf273d9e6e643f571c434753059eb01a902204aa761f44e89b55af0e2fa0caef580401a4ba61eebf8bc29020ce23f6fab1ee2012102661ac805eef8015c7c8d617c65ef327c4f2272fd5d9e97456a0d32d3bcf6f563ffffffff0288130000000000001976a91430a5d35558ade668b8829a2a0f60a3f10358327e88ac306f0100000000001976a914760fdb3483204406ddb73a45b20b7c9be61d0a7e88ac00000000"

请注意,这里没有键值对。我正在尝试使用“流水线”来发布此内容,但我不断收到以下错误:

这是我尝试使用的代码:

我做错了什么?

编辑:

我试图调用的 API:

http://docs.coinprism.apiary.io/#reference/transaction-signing-and-broadcasting/push-a-signed-raw-transaction-to-the-network/post?console=1

0 投票
1 回答
1231 浏览

performance - spray-client throwing "Too many open files" exception when giving more concurrent requests

I have a spray http client which is running in a server X, which will make connections to server Y. Server Y is kind of slow(will take 3+ sec for a request)

This is my http client code invocation:

These are the configurations I have in application.conf:

Now I tried to abuse the server X with large number of concurrent requests(using ab with n=1000 and c=100).

Till 900 requests it went fine. After that the server threw lot of exceptions and I couldn't hit the server after that. These are the exceptions:

[info] [ERROR] [03/28/2015 17:33:13.276] [squbs-akka.actor.default-dispatcher-6] [akka://squbs/system/IO-TCP/selectors/$a/0] Accept error: could not accept new connection

[info] java.io.IOException: Too many open files [info] at sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method) [info] at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:241) [info] at akka.io.TcpListener.acceptAllPending(TcpListener.scala:103)

and on further hitting the same server, it threw the below exception:

[info] [ERROR] [03/28/2015 17:53:16.735] [hcp-client-akka.actor.default-dispatcher-6] [akka://hcp-client/system/IO-TCP/selectors] null [info] akka.actor.ActorInitializationException: exception during creation

[info] at akka.actor.ActorInitializationException$.apply(Actor.scala:164)

[info] at akka.actor.ActorCell.create(ActorCell.scala:596)

[info] Caused by: java.lang.reflect.InvocationTargetException

[info] at sun.reflect.GeneratedConstructorAccessor59.newInstance(Unknown Source)

[info] Caused by: java.io.IOException: Too many open files [info] at sun.nio.ch.IOUtil.makePipe(Native Method)

I was previously using apache http client(which was synchronous) which was able to handle 10000+ requests with concurrency of 100.

I'm not sure I'm missing something. Any help would be appreciated.

0 投票
1 回答
1641 浏览

scala - 由于 SSL 连接已经在喷雾中关闭错误,如何修复 Dropping Close

我正在调用 API,但大多数时候我不断收到错误消息:“<strong>Dropping Close 因为 SSL 连接已经关闭”和“<strong>过早的连接关闭(服务器没有出现支持请求流水线)。” 就像 90% 的时间我得到那个错误,意思是:在非常罕见的情况下,查询确实返回了它应该返回的数据。

为了确保这不是 API 的服务器问题,我使用 Node.js(Express 和 Request 库)复制了相同的查询,并且每次都能正常工作。这让我几乎可以肯定是喷虫

这是代码示例

错误详情

而且我能够在所有这些版本中重现错误

0 投票
1 回答
336 浏览

scala - 喷雾客户端中的解组器隐式解析

我有一个管道:

编译器说他不能find implicit value for parameter unmarshaller: spray.httpx.unmarshalling.FromResponseUnmarshaller[MyCustomType]

我已经像在此处的喷雾文档中的示例中那样完成了它。为什么它不能解决隐含?

EDIT val pipeline = sendReceive ~> unmarshal[MyCustomType]用于匿名类的方法。我发现如果我在那个匿名类中声明我的所有 jsonFomats(我的意思是MyJsonProtocol我替换为匿名类的东西)一切正常。

所以问题是为什么这不适用于匿名类?

0 投票
1 回答
606 浏览

scala - 在喷雾客户端的请求级 api 中处理 http 响应

我正在使用喷雾客户端的请求级别 api 来请求服务器。

这是我的代码:

我没有得到预期的回应。执行上下文将失败。我正在接收ChunkedResponseStart(HttpResponse(200 OK,Empty,List(Transfer-Encoding: chunked)而不是 HttpResponse 本身,并且 mapTo 失败了。

我不确定为什么会发生这种情况以及如何解决。

0 投票
2 回答
199 浏览

spray - 从 Spray-can 中的 POST 请求中获取文件名

我正在使用 Spray-can 托管一个 REST 服务,用户可以将文件上传到该服务。下面给出了侦听传入请求的代码块:

我使用此 curl 命令上传文件:

我面临的挑战是我无法从请求中获取文件名“inputFile.csv”,尽管我从“实体”对象中获取数据。我尝试仔细研究 API,但找不到任何获取文件名的方法。

我的目标是确保我只允许上传 csv 文件。