Coder Social home page Coder Social logo

Comments (28)

Barenboim avatar Barenboim commented on August 16, 2024

怎么看都好像被云主机限制了😂

你自定义协议通信部分没有什么问题,就是http server收不到40000字节上以上的请求是吗?

from workflow.

Barenboim avatar Barenboim commented on August 16, 2024

另外你这个自定义协议,可以用我们protocol里的TLVMessage。

from workflow.

253027 avatar 253027 commented on August 16, 2024

怎么看都好像被云主机限制了😂

你自定义协议通信部分没有什么问题,就是http server收不到40000字节上以上的请求是吗?

是的40000以上就不行了,那我再去看看😭

from workflow.

253027 avatar 253027 commented on August 16, 2024

另外你这个自定义协议,可以用我们protocol里的TLVMessage。

好的,主要刚开始接触workflow,我想都试试后面会尝试的😁

from workflow.

Barenboim avatar Barenboim commented on August 16, 2024

怎么看都好像被云主机限制了😂
你自定义协议通信部分没有什么问题,就是http server收不到40000字节上以上的请求是吗?

是的40000以上就不行了,那我再去看看😭

嗯嗯,看看你的云主机有没有什么参数限制。我觉得某些安全机制可能会让云主机限制http请求的大小,避免用户的http server被攻击。

from workflow.

253027 avatar 253027 commented on August 16, 2024

怎么看都好像被云主机限制了😂
你自定义协议通信部分没有什么问题,就是http server收不到40000字节上以上的请求是吗?

是的40000以上就不行了,那我再去看看😭

嗯嗯,看看你的云主机有没有什么参数限制。我觉得某些安全机制可能会让云主机限制http请求的大小,避免用户的http server被攻击。

这边测试过了,没有限制带宽。忘记补充了,我的做业务的服务器直接读的workflow发过来的数据自己手动解析的,并未使用worklfow当做另一端,两边不是对称的(都使用的workflow)。这样会有问题吗?

from workflow.

Barenboim avatar Barenboim commented on August 16, 2024

都是http协议,无论如何都是可以互通的啊。

你尝试用我们tutorial里的http_echo_server,让外部发一个40KB以上的请求,看看能不能立刻响应。

from workflow.

Barenboim avatar Barenboim commented on August 16, 2024

params.peer_response_timeout = 100;
这一行也可以先去掉试试。这个表示请求数据每两个包之间最多间隔100ms。

from workflow.

253027 avatar 253027 commented on August 16, 2024

params.peer_response_timeout = 100; 这一行也可以先去掉试试。这个表示请求数据每两个包之间最多间隔100ms。

这个是我做业务读TCP数据的代码

#include "../include/iodevice.h"
#include "../include/utility.h"

IoDevice::IoDevice(int socket) : _socket(socket) {}

int IoDevice::boundary_recv(std::string &buf)
{
    char buffer[1024];
    int ret = ::recv(_socket, buffer, 4, MSG_WAITALL);
    ERROR_CHECK(ret == -1, "boundary recv error which is -1");
    if (ret == 0)
        return 0;
    size_t len = *(size_t *)buffer, hash_recv = 0;
    while ((ret = ::recv(_socket, buffer, std::min(1024UL, len - hash_recv), MSG_WAITALL)) > 0)
    {
        if (ret == -1 && (errno & EAGAIN))
            continue;
        else if (ret == -1)
            return -1;
        buf.append(buffer, ret), hash_recv += ret;
    }
    return hash_recv;
}

int IoDevice::boundary_send(const std::string &buf)
{
    int len = buf.size(), has_send = 0;
    int ret = ::send(_socket, &len, sizeof(len), 0);
    ERROR_CHECK(ret == -1, "boundary send data size error");
    return send(buf);
}

int IoDevice::send(const std::string &buf)
{
    int ret;
    size_t len = buf.size(), has_send = 0;
    while ((ret = ::send(_socket, buf.data() + has_send, std::min(1024UL, len - has_send), MSG_DONTWAIT)) > 0)
    {
        if (ret == -1 && (errno & EWOULDBLOCK))
            continue;
        else if (ret == -1)
            return -1;
        has_send += ret;
    }
    return has_send;
}

int IoDevice::recv(std::string &buf)
{
    int ret = 0, bytes_read = 0;
    char buffer[1024];
    while ((ret = ::read(_socket, buffer, 1024)) > 0)
    {
        if (ret == -1)
            return (errno & EAGAIN) ? bytes_read : -1;
        buf.append(buffer, ret), bytes_read += ret;
    }
    return bytes_read;
}

我的疑问是在这个问题上面,create_client_task是不是有什么确认机制,确认连接存在呢?这边刚测试了100000字节的基本上发一多半链接就关闭了。我明天会试试workflow对称收发。

PrivateTask *tcp_task = NTF::create_client_task(TT_TCP, "tcp://xxxxxxxx:xxxxx", 1, PrivateProtocalCallback);

from workflow.

Barenboim avatar Barenboim commented on August 16, 2024

你编码的时候执行了htonl转成网络序了,但boundary_recv里没有转啊。那肯定是错误的。

from workflow.

Barenboim avatar Barenboim commented on August 16, 2024

并且,encode时用的是uint32_t,接收又使用size_t。

还有,(errno & EAGAIN)又是什么意思,不应该是(errno == EAGAIN)吗?

from workflow.

253027 avatar 253027 commented on August 16, 2024

并且,encode时用的是uint32_t,接收又使用size_t。

还有,(errno & EAGAIN)又是什么意思,不应该是(errno == EAGAIN)吗?

这一块确实写的有问题已经改正了,htonl转成网络序我是在发送数据之前转换过了,IODevice只负责发送数据。改正之后再次测试,本地确实可以收发,收一次数据的过程基本收一半多断开了。我将两个进程一起放在云服务器上,最后的HTTP报文是可以完整收到的,说明服务器带宽没有限制

6832
head: 726560
13068 5808 1452 2904 5808
1452 2904 2904 2904 2904 
2904 2904 2904 2904 2904 
2904 2904 2904 2904 2904 
2904 2904
Error: Connection timed out

打印信息实在这里加上的

int PrivateProtocal::append(const void *buf, size_t size)
{
    std::cout << size << "\n";
    // 获取头部信息直到获取完毕
    if (this->head_received < 4)
    {
        void *p = &this->head[head_received];
        size_t need = std::min(4 - this->head_received, size);
        size -= need, this->head_received += need;
        memcpy(p, buf, need);
        if (size <= 0)
            return 0;
        buf = (const char *)buf + need;
        p = this->head;
        this->body_size = ntohl(*(u_int32_t *)p);
        if (this->body_size > this->size_limit)
        {
            errno = EMSGSIZE;
            return -1;
        }
        this->body = (char *)malloc(sizeof(char) * this->body_size);
        if (!this->body)
            return -1;
        this->body_received = 0;
        std::cout << "head: " << this->body_size << "\n";
    }
    ...................

from workflow.

253027 avatar 253027 commented on August 16, 2024

你编码的时候执行了htonl转成网络序了,但boundary_recv里没有转啊。那肯定是错误的。

这是我云服务器发给本地HTTP网关的数据,我在IODevice发送消息data前会再发送一个4字节的头部指定此次发送数据大小,不知道这样对不对

void task(void *eventloop, int socket, int type, const std::string &query)
{
    // std::cout << pthread_self() << std::endl;
    //  std::this_thread::sleep_for(std::chrono::seconds(1));
    std::string res;
    if (type == 1)
        res = Dictionary::GetInstance()->query(query), type = 100;
    else if (type == 2)
        res = webquery.query(query), type = 200;
    std::cout << "取得" << res.size() << "\n";
    std::string data(8 + res.size(), '\0');
    *(int *)data.data() = ::htonl(4 + res.size());    //根据PrivateProtocal指定协议的头部大小
    *((int *)data.data() + 1) = type;     //这一块自己用的数据
    ::memcpy(data.data() + 8, res.data(), res.size());   //这一块自己用的数据

    EventLoop *loop = (EventLoop *)eventloop;
    loop->appendSendPoll(std::make_pair(socket, data));
}

from workflow.

Barenboim avatar Barenboim commented on August 16, 2024

你真正上线还是直接用我们的TLVMessage吧,完全就是你需要的结构。你代码这写法,我也搞不清楚还会有什么问题。

from workflow.

253027 avatar 253027 commented on August 16, 2024

你真正上线还是直接用我们的TLVMessage吧,完全就是你需要的结构。你代码这写法,我也搞不清楚还会有什么问题。

from workflow.

Barenboim avatar Barenboim commented on August 16, 2024

http server从外网接收大数据问题已经解决了是吧?

from workflow.

253027 avatar 253027 commented on August 16, 2024

http server从外网接收大数据问题已经解决了是吧?

😭没,我想换条路。

from workflow.

Barenboim avatar Barenboim commented on August 16, 2024

from workflow.

253027 avatar 253027 commented on August 16, 2024

Response timeout那个去掉了没?

---原始邮件--- 发件人: @.> 发送时间: 2024年5月7日(周二) 晚上7:31 收件人: @.>; 抄送: @.@.>; 主题: Re: [sogou/workflow] workflow充当HTTP网关时数据量太大就收不全 (Issue #1548) http server从外网接收大数据问题已经解决了是吧? 😭没,我想换条路。 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

你说过后我就去掉了

from workflow.

Barenboim avatar Barenboim commented on August 16, 2024

from workflow.

253027 avatar 253027 commented on August 16, 2024

用我们tutorial里的http echo server试过了吗?

---原始邮件--- 发件人: @.> 发送时间: 2024年5月7日(周二) 晚上7:59 收件人: @.>; 抄送: @.@.>; 主题: Re: [sogou/workflow] workflow充当HTTP网关时数据量太大就收不全 (Issue #1548) Response timeout那个去掉了没? … ---原始邮件--- 发件人: @.> 发送时间: 2024年5月7日(周二) 晚上7:31 收件人: @.>; 抄送: @.@.>; 主题: Re: [sogou/workflow] workflow充当HTTP网关时数据量太大就收不全 (Issue #1548) http server从外网接收大数据问题已经解决了是吧? 😭没,我想换条路。 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.> 你说过后我就去掉了 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.>

试过了云服务器发200K左右本地不能立刻收到有延迟

from workflow.

Barenboim avatar Barenboim commented on August 16, 2024

from workflow.

253027 avatar 253027 commented on August 16, 2024

这。。。是不是rtt大啊。超过16k的话,因为tcp窗口的原因,会达到数个rtt。延迟是多久?

---原始邮件---
发件人: @.>
发送时间: 2024年5月8日(周三) 凌晨0:36
收件人: @.
>;
抄送: @.@.>;
主题: Re: [sogou/workflow] workflow充当HTTP网关时数据量太大就收不全 (Issue #1548)

用我们tutorial里的http echo server试过了吗?

---原始邮件--- 发件人: @.> 发送时间: 2024年5月7日(周二) 晚上7:59 收件人: @.>; 抄送: @.@.>; 主题: Re: [sogou/workflow] workflow充当HTTP网关时数据量太大就收不全 (Issue #1548) Response timeout那个去掉了没? … ---原始邮件--- 发件人: @.> 发送时间: 2024年5月7日(周二) 晚上7:31 收件人: @.>; 抄送: @.@.>; 主题: Re: [sogou/workflow] workflow充当HTTP网关时数据量太大就收不全 (Issue #1548) http server从外网接收大数据问题已经解决了是吧? 😭没,我想换条路。 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.> 你说过后我就去掉了 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.>

试过了云服务器发200K左右本地不能立刻收到有延迟


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: @.***>

怎么看rtt时间呢太底层了,不熟悉

from workflow.

Barenboim avatar Barenboim commented on August 16, 2024

from workflow.

253027 avatar 253027 commented on August 16, 2024

Ping一下啊。。。

---原始邮件---
发件人: @.>
发送时间: 2024年5月8日(周三) 凌晨0:43
收件人: @.
>;
抄送: @.@.>;
主题: Re: [sogou/workflow] workflow充当HTTP网关时数据量太大就收不全 (Issue #1548)

这。。。是不是rtt大啊。超过16k的话,因为tcp窗口的原因,会达到数个rtt。延迟是多久?

---原始邮件---
发件人: @.>
发送时间: 2024年5月8日(周三) 凌晨0:36
收件人: @.>;
抄送: @.@.>;
主题: Re: [sogou/workflow] workflow充当HTTP网关时数据量太大就收不全 (Issue #1548)

用我们tutorial里的http echo server试过了吗?

---原始邮件--- 发件人: @.> 发送时间: 2024年5月7日(周二) 晚上7:59 收件人: @.>; 抄送: @.@.>; 主题: Re: [sogou/workflow] workflow充当HTTP网关时数据量太大就收不全 (Issue #1548) Response timeout那个去掉了没? … ---原始邮件--- 发件人: @.> 发送时间: 2024年5月7日(周二) 晚上7:31 收件人: @.>; 抄送: @.@.>; 主题: Re: [sogou/workflow] workflow充当HTTP网关时数据量太大就收不全 (Issue #1548) http server从外网接收大数据问题已经解决了是吧? 😭没,我想换条路。 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.> 你说过后我就去掉了 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.>

试过了云服务器发200K左右本地不能立刻收到有延迟


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: @.***>

怎么看rtt时间呢太底层了,不熟悉


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: @.***>

有没有别的工具,问题就是ping不通啊

from workflow.

253027 avatar 253027 commented on August 16, 2024

Ping一下啊。。。

---原始邮件---
发件人: @.>
发送时间: 2024年5月8日(周三) 凌晨0:43
收件人: @.
>;
抄送: @.@.>;
主题: Re: [sogou/workflow] workflow充当HTTP网关时数据量太大就收不全 (Issue #1548)

这。。。是不是rtt大啊。超过16k的话,因为tcp窗口的原因,会达到数个rtt。延迟是多久?

---原始邮件---
发件人: @.>
发送时间: 2024年5月8日(周三) 凌晨0:36
收件人: @.>;
抄送: @.@.>;
主题: Re: [sogou/workflow] workflow充当HTTP网关时数据量太大就收不全 (Issue #1548)

用我们tutorial里的http echo server试过了吗?

---原始邮件--- 发件人: @.> 发送时间: 2024年5月7日(周二) 晚上7:59 收件人: @.>; 抄送: @.@.>; 主题: Re: [sogou/workflow] workflow充当HTTP网关时数据量太大就收不全 (Issue #1548) Response timeout那个去掉了没? … ---原始邮件--- 发件人: @.> 发送时间: 2024年5月7日(周二) 晚上7:31 收件人: @.>; 抄送: @.@.>; 主题: Re: [sogou/workflow] workflow充当HTTP网关时数据量太大就收不全 (Issue #1548) http server从外网接收大数据问题已经解决了是吧? 😭没,我想换条路。 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.> 你说过后我就去掉了 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.>

试过了云服务器发200K左右本地不能立刻收到有延迟


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: @.***>

怎么看rtt时间呢太底层了,不熟悉


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: @.***>

我自己再试试吧,您早点休息😁

from workflow.

Barenboim avatar Barenboim commented on August 16, 2024

from workflow.

253027 avatar 253027 commented on August 16, 2024

你connect一下看看多长时间连上也行啊

---原始邮件--- 发件人: @.> 发送时间: 2024年5月8日(周三) 凌晨0:52 收件人: @.>; 抄送: @.@.>; 主题: Re: [sogou/workflow] workflow充当HTTP网关时数据量太大就收不全 (Issue #1548) Ping一下啊。。。
---原始邮件--- 发件人: @.> 发送时间: 2024年5月8日(周三) 凌晨0:43 收件人: @.>; 抄送: @.@.>; 主题: Re: [sogou/workflow] workflow充当HTTP网关时数据量太大就收不全 (Issue #1548) 这。。。是不是rtt大啊。超过16k的话,因为tcp窗口的原因,会达到数个rtt。延迟是多久?
---原始邮件--- 发件人: @.> 发送时间: 2024年5月8日(周三) 凌晨0:36 收件人: @.>; 抄送: @.@.>; 主题: Re: [sogou/workflow] workflow充当HTTP网关时数据量太大就收不全 (Issue #1548) 用我们tutorial里的http echo server试过了吗? … ---原始邮件--- 发件人: @.> 发送时间: 2024年5月7日(周二) 晚上7:59 收件人: @.>; 抄送: @.@.>; 主题: Re: [sogou/workflow] workflow充当HTTP网关时数据量太大就收不全 (Issue #1548) Response timeout那个去掉了没? … ---原始邮件--- 发件人: @.> 发送时间: 2024年5月7日(周二) 晚上7:31 收件人: @.>; 抄送: @.@.>; 主题: Re: [sogou/workflow] workflow充当HTTP网关时数据量太大就收不全 (Issue #1548) http server从外网接收大数据问题已经解决了是吧? 😭没,我想换条路。 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.> 你说过后我就去掉了 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.> 试过了云服务器发200K左右本地不能立刻收到有延迟 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.> 怎么看rtt时间呢太底层了,不熟悉 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.> 我自己再试试吧,您早点休息😁 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

Elapsed time: 0.023836986 seconds
connect函数返回时间,说明没问题啊。

from workflow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.