小编Ale*_*hev的帖子

curl: (35) 对等方重置 TCP 连接

我想从 CentOS 设置电报机器人 webhook,但收到错误:

curl: (35) TCP connection reset by peer
Run Code Online (Sandbox Code Playgroud)

我的请求:

curl -F "url=https://12.34.56.78:8443" \
-F "certificate=@/home/mts/mtspredbot/mtspredbot.pem" \
https://api.telegram.org/xxxxxxxxxxxxxxxxxxxxxxx/setWebhook
Run Code Online (Sandbox Code Playgroud)

这个问题与我的输出连接有关还是与其他问题有关?

使用 -v 选项:

$ curl -v -F "url=https://12.34.56.78:8443" -F "certificate=@/home/mts/mtspredbot/mtspredbot.pem" https://api.telegram.org/token_here/setWebhook
* About to connect() to api.telegram.org port 443 (#0)
*   Trying 149.154.167.220...
* Connected to api.telegram.org (149.154.167.220) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* NSS error -5961 (PR_CONNECT_RESET_ERROR)
* TCP connection reset by peer
* Closing connection 0
curl: (35) …
Run Code Online (Sandbox Code Playgroud)

curl telegram-bot

6
推荐指数
0
解决办法
1万
查看次数

ZIO Fiber或Else生成异常消息

我想在ZIO Fibers上使用组合器orElse。从文档:

如果第一个光纤成功,则组成的光纤将成功,其结果;否则,组成的光纤将以第二根光纤的出口值完成(无论成功还是失败)。

import zio._
import zio.console._

object MyApp extends App {

  def f1 :Task[Int] = IO.fail(new Exception("f1 fail"))
  def f2 :Task[Int] = IO.succeed(2)

  val myAppLogic =
    for {
      f1f <- f1.fork
      f2f <- f2.fork
      ff  =  f1f.orElse(f2f)
      r   <- ff.join
      _   <- putStrLn(s"Result is [$r]")
    } yield ()

  def run(args: List[String]) =
    myAppLogic.fold(_ => 1, _ => 0)
}
Run Code Online (Sandbox Code Playgroud)

我在控制台中使用sbt运行它。并输出:

[info] Running MyApp
Fiber failed.
A checked error was not handled.
java.lang.Exception: f1 fail
        at MyApp$.f1(MyApp.scala:6)
        at MyApp$.<init>(MyApp.scala:11)
        at …
Run Code Online (Sandbox Code Playgroud)

scala zio

5
推荐指数
1
解决办法
57
查看次数

org.http4s.client 带有标题和 UriForm 的帖子

使用 org.http4s.client 无法找到如何将标头和 UriForm 与 Post 请求一起发送。

import org.http4s.client.dsl.io._
import org.http4s.Method._

val lstHeader: List[Header] = List(
  Header("Accept", "application/json")
  , Header("Accept-Charset", "utf-8")
  , Header("Accept-Encoding", "gzip")
)

val formData :UrlForm = UrlForm(
  "username" -> "user",
  "enc_password" -> "password",
  "queryParams" -> "{}",
  "optIntoOneTap" -> "false"
)

val req1 = POST(
  formData,
  uri"https://www.instagram.com/accounts/login/ajax/"
)

val req2: Request[IO] = Request[IO](
  Method.POST,
  uri"https://www.instagram.com/accounts/login/ajax/",
  HttpVersion.`HTTP/2.0`,
  Headers(lstHeader)
)
Run Code Online (Sandbox Code Playgroud)

req1 没有我的标题 req2 没有表单数据

谢谢

scala http-post http4s

5
推荐指数
1
解决办法
1555
查看次数

ZIO IO.collectAll 和 ZIO.collectAllPar 在一起

我有一个下一个任务,有 N db 查询(例如 3 - Seq(10,20,30))和迭代计数 = 4。我想使用 ZIO 和下一个:顺序执行迭代和内部迭代评估效果并行。

简化的代码看起来像这样

import zio._
import zio.console._

case class Res(iterNum :Int, dataValue :Int)

val execUnpure :(Int,Int) => Res = (iterNum,dataValue) =>
 Res(iterNum, dataValue)

val exec :(Int,Int) => Task[Res] = (iterNum,dataValue) =>
  Task.succeed(Res(iterNum, dataValue))

val evalEffectsParallel: (Int, Seq[Int]) => Task[Seq[Res]] =
  (iterNum, sqLoadConf) =>
    ZIO.collectAllPar(
      sqLoadConf.map(lc => 
        for {
          //here I open NEW db session for this exec.
          tr: Res <- exec(iterNum, lc)
        } yield tr

      )
    )

val seqParallelExec: (Int, Seq[Int]) …
Run Code Online (Sandbox Code Playgroud)

scala zio

1
推荐指数
1
解决办法
828
查看次数

标签 统计

scala ×3

zio ×2

curl ×1

http-post ×1

http4s ×1

telegram-bot ×1