Giter VIP home page Giter VIP logo

kuma's Introduction

kuma

kuma is a multi-platform support network library developed in C++. It implements interfaces for TCP/UDP/Multicast/HTTP/HTTP2/WebSocket/timer that drove by event loop. kuma supports epoll/poll/WSAPoll/IOCP/kqueue/io_uring/select on platform Linux/Windows/OSX/iOS/Android.

Features

  • Support epoll, poll/WSAPoll, IOCP, kqueue, io_uring and select
  • Portable/cross platform(linux, windows, macOS, iOS and Android)
  • Support OpenSSL 1.0 and 1.1
  • IPv6 support
  • Flexible/Scalable timer manager
  • Support HTTP compression gzip and deflate
  • Support secure HTTP/2 and HTTP/1.1 upgrade to HTTP/2 (rfc7540, rfc7541)
  • Support WebSocket(rfc6455) and extension permessage_deflate(rfc7692)
  • Support WebSocket over HTTP/2(rfc8441)
  • All interface objects, except Timer, are not thread-safe, must run on their EventLoop thread, but close method is thread-safe

Get source code

git clone https://github.com/Jamol/kuma.git
git submodule update --init

Build

define macro KUMA_HAS_OPENSSL to enable openssl

build dependency libkev firstly

python ./third_party/libkev/bld/your_os/build_your_os.py

iOS

open project bld/ios/kuma with xcode and build it

MAC

open project bld/mac/kuma with xcode and build it

Windows

open bld/windows/kuma.sln with VS2017 and build it

Linux

$ cd src
$ make

Android

[deprecated]

$ cd src/jni
$ ndk-build

kuma .aar:

open android/kuam in Android Studio
or
python bld/android/build_android_aar.py

kuma .so:

python bld/android/build_android_so.py

demo:

open test/android/kmtest in Android Studio

CMake build

CMake is also supported:
python ./bld/your_os/build_your_os.py --msvc vs2017/vs2019/vs2022

OpenSSL

certificates location is by default in /path-to-your-excutable/cert.

copy all CA certificates used to cert/ca.pem
copy your server certificate to cert/server.pem
copy your server private key to cert/server.key

Simple example

Please refer to test for more examples

client

#include "kmapi.h"
#include "libkev/src/utils/defer.h"

using namespace kuma;

int main(int argc, char *argv[])
{
    kuma::init();
    DEFER(kuma::fini());
    
    EventLoop main_loop(PollType::NONE);
    if (!main_loop.init()) {
        printf("failed to init EventLoop\n");
        return -1;
    }
    
    // WebSocket example
    WebSocket ws(&main_loop, "HTTP/1.1");
    // setup callbacks
    ws.setOpenCallback([] (KMError err) {
        printf("ws.onOpen, err=%d\n", err);
    });
    ws.setDataCallback([] (KMBuffer &data, bool is_text, bool is_fin) {
        printf("ws.onData, len=%lu\n", data.chainLength());
    });
    ws.setWriteCallback([] (KMError err) {
        printf("ws.onWrite, write available\n");
    });
    ws.setErrorCallback([] (KMError err) {
        printf("ws.onError, err=%d\n", err);
    });
    ws.setSubprotocol("jws");
    ws.setOrigin("www.jamol.cn");
    ws.connect("wss://127.0.0.1:8443/");

    // HTTP client example
    HttpRequest http(&main_loop);
    // setup callbacks
    http.setDataCallback([] (KMBuffer &buf) {
        printf("http.onData, len=%lu\n", buf.chainLength());
    });
    http.setWriteCallback([] (KMError err) {
        printf("http.onWrite, write available\n");
    });
    http.setErrorCallback([] (KMError err) {
        printf("http.onError, err=%d\n", err);
    });
    http.setHeaderCompleteCallback([&] {
        printf("http.onHeader, status=%d\n", http.getStatusCode());
        http.forEachHeader([] (const std::string &name, const std::string &value) {
            printf("http.onHeader, name=%s, value=%s\n",
                name.c_str(), value.c_str());
            return true;
        });
    });
    http.setResponseCompleteCallback([&] {
        printf("http.onResponseComplete\n");
    });
    // send HTTP request
    http.sendRequest("GET", "http://www.baidu.com");
    
    Timer timer(&main_loop);
    timer.schedule(1000, Timer::Mode::ONE_SHOT, [] {
        printf("onTimer\n");
    });
    
    main_loop.loop();
    return 0;
}

server

#include "kmapi.h"
#include "libkev/src/utils/defer.h"

using namespace kuma;

int main(int argc, char *argv[])
{
    kuma::init();
    DEFER(kuma::fini());
    
    EventLoop main_loop(PollType::NONE);
    if (!main_loop.init()) {
        printf("failed to init EventLoop\n");
        return -1;
    }
    
    WebSocket ws(&main_loop);
    ws.setOpenCallback([] (KMError err) {
        printf("ws.onOpen, err=%d\n", err);
    });
    ws.setDataCallback([] (KMBuffer &data, bool is_text, bool is_fin) {
        printf("ws.onData, len=%lu\n", data.chainLength());
    });
    ws.setWriteCallback([] (KMError err) {
        printf("ws.onWrite, write available\n");
    });
    ws.setErrorCallback([] (KMError err) {
        printf("ws.onError, err=%d\n", err);
    });
    
    TcpListener server(&main_loop);
    server.setAcceptCallback([&ws] (SOCKET_FD fd, const char* ip, uint16_t port) -> bool {
        printf("server.onAccept, ip=%s\n", ip);
        ws.setSslFlags(SSL_ENABLE);
        ws.attachFd(fd, nullptr, [] (KMError err) {
            printf("ws.onHandshake, err=%d\n", err);
            return true;
        });
        return true;
    });
    server.setErrorCallback([] (KMError err) {
        printf("server.onError, err=%d\n", err);
    });
    auto ret = server.startListen("0.0.0.0", 8443);
    if (ret != KMError::NOERR) {
        printf("failed to listen on 8443\n");
    }
    
    main_loop.loop();
    return 0;
}

kuma's People

Contributors

jamol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kuma's Issues

linux compile error - http2 reuse bug patch version

hi...

i just download & compile souce..
but compile failed..

kmapi.cpp: In constructor ‘kuma::EventLoop::EventLoop(kuma::PollType)’:
kmapi.cpp:79:43: error: call of overloaded ‘ImplHelper(kuma::PollType&)’ is ambiguous
auto h = new EventLoopHelper(poll_type);
^
kmapi.cpp:79:43: note: candidates are:
kmapi.cpp:60:5: note: kuma::ImplHelper::ImplHelper(Args&& ...) [with Args = {kuma::PollType&}; Impl = kuma::EventLoop::Impl]
ImplHelper(Args&&... args)
^
kmapi.cpp:53:5: note: kuma::ImplHelper::ImplHelper(Args& ...) [with Args = {kuma::PollType}; Impl = kuma::EventLoop::Impl]
ImplHelper(Args&... args)
^
kmapi.cpp:47:8: note: kuma::ImplHelperkuma::EventLoop::Impl::ImplHelper(const kuma::ImplHelperkuma::EventLoop::Impl&)
struct ImplHelper {
^
kmapi.cpp:47:8: note: kuma::ImplHelperkuma::EventLoop::Impl::ImplHelper(kuma::ImplHelperkuma::EventLoop::Impl&&)
make: *** [../objs/linux/kmapi.o] error 1
[pgfe@pgfe1:/UDC/INFRA/OpenLib/KUMA/kuma-master/src]

wss can't receive data

hello Jamol,
I run the test demo as a wss server:
./server wss://0.0.0.0:6086

 and use a webpage to send a wss request:

wss://192.168.31.232:6086
after handshake ,I send a message(binary data),it returned: (Opcode -1).The server log shows:

INFO: [140191080888384] AcceptorBase_2:: onAccept, fd=16, peer_ip=192.168.31.147, peer_port=50079
TcpServer::onAccept, fd=16, ip=192.168.31.147, port=50079, proto=5
INFO: [140190551111424] TcpSocket_15:: attachFd, fd=16, flags=1
INFO: [140190551111424] SocketBase_16:: attachFd, fd=16, state=0
INFO: [140190551111424] EPoll::registerFd, fd=16, ev=2147483677
INFO: [140190551111424] TcpSocket_15:: startSslHandshake, ssl_role=1, fd=16
INFO: [140190551111424] SioHandler_16:: handshake, success, fd=16
INFO: [140190551111424] TcpSocket_15:: checkSslHandshake, completed, err=0
INFO: [140190551111424] WebSocket_14:: onStateOpen
ERROR: [140190551111424] SioHandler_16:: receive, SSL_read failed, fd=16, ssl_status=0, ssl_err=5, os_err=0, err_msg=
INFO: [140190551111424] SocketBase_16:: close, state=3
INFO: [140190551111424] EPoll::unregisterFd, fd=16, max_fd=1023
INFO: [140190551111424] TcpSocket_15:: close
INFO: [140190551111424] WebSocket_14:: onError, err=-9

it can't receive msg from SSL_read function, I anlysysed the ssl_err,it just say,SSL_ERROR_SYSCALL,it's a bottom error. I can't find the answer, hope to get help from you.

you can contact me with email:[email protected]

SSL_ERROR

image
http is ok, but https always returns -15

MBEDTLS support

Have any plan to support mbedtls?
Openssl is too big for embended systems.

Android Bug No implementation found for int com.jamol.kuma.WebSocket.connect

No implementation found for int com.jamol.kuma.WebSocket.connect(java.lang.String) (tried Java_com_jamol_kuma_WebSocket_connect and Java_com_jamol_kuma_WebSocket_connect__Ljava_lang_String_2)
2023-11-07 15:00:43.644 8361-8580 AndroidRuntime com.feihong.tx100test E FATAL EXCEPTION: Thread-5
Process: com.feihong.tx100test, PID: 8361
java.lang.UnsatisfiedLinkError: No implementation found for int com.jamol.kuma.WebSocket.connect(java.lang.String) (tried Java_com_jamol_kuma_WebSocket_connect and Java_com_jamol_kuma_WebSocket_connect__Ljava_lang_String_2)
at com.jamol.kuma.WebSocket.connect(Native Method)
at com.jamol.kuma.WebSocket.open(WebSocket.java:11)

Can support Reliable UDP and Reliable MultiCast?

Reliable udp transmission is widely used in real business,There are now many reliable UDP unicast and multicast protocols. as:QUIC,KCP,NORM(Negative-ACKnowledgment Oriented Reliable Multicast),PGM 。thanks!

Linux make err:

Linux:
cd src
make

Errors:
g++: error: ../third_party/libkev/lib/linux/Release/libkev.a: No such file or directory
g++: error: ../third_party/libkev/lib/linux/Release/libkev.a: No such file or directory

how to dump backtrace?

Hi
this is a good project but it is too hard for me, so I want to debug it with backtrace step
by step .
in kmtrace.h I add below:
#define KUMA_DUMPTRACE(x)
do{
std::cout<<getObjKey()<<":: "<<x<<"...\n";
Backtrace();
}while(0)

void DumpBacktrace();

in kmtrace.cpp add:

#if defined(GLIBCXX) && !defined(UCLIBC)
#include <cxxabi.h>
#include <execinfo.h>
#endif

void DumpBacktrace() {
#if defined(GLIBCXX) && !defined(UCLIBC)
void* trace[100];
int size = backtrace(trace, sizeof(trace) / sizeof(trace));
char
* symbols = backtrace_symbols(trace, size);
printf("\n==== C stack trace ===============================\n\n");
if (size == 0) {
printf("(empty)\n");
} else if (symbols == NULL) {
printf("(no symbols)\n");
} else {
for (int i = 1; i < size; ++i) {
char mangled[201];
if (sscanf(symbols[i], "%[^(]%[(]%200[^)+]", mangled) == 1) { // NOLINT
printf("%2d: ", i);
int status;
size_t length;
char* demangled = abi::__cxa_demangle(mangled, NULL, &length, &status);
printf("%s\n", demangled != NULL ? demangled : mangled);
free(demangled);
} else {
// If parsing failed, at least print the unparsed symbol.
printf("%s\n", symbols[i]);
}
}
}
free(symbols);
#endif
}

so if I want dump backtrace, i use it , for : KUMA_DUMPTRACE("sendPreface");
I get this result:
==== C stack trace ===============================

1: kuma::H2Connection::Impl::sendPreface()
2: kuma::H2Connection::Impl::attachSocket(kuma::TcpSocket::Impl&&, kuma::HttpParser::Impl&&, void const*, unsigned long)
3: kuma::H2Connection::attachSocket(kuma::TcpSocket&&, kuma::HttpParser&&, void const*, unsigned long)
./server() [0x413836]
./server() [0x409bf5]
./server() [0x415a1b]
./server() [0x415c6d]
./server() [0x415639]
./server() [0x41679d]
10: std::function<void (kuma::KMError)>::operator()(kuma::KMError) const
11: kuma::TcpSocket::Impl::onReceive(kuma::KMError)
../../bin/linux/libkuma.so(+0x1112ab) [0x7f14752e52ab]
../../bin/linux/libkuma.so(+0x112c33) [0x7f14752e6c33]
14: std::function<void (kuma::KMError)>::operator()(kuma::KMError) const
15: kuma::SocketBase::onReceive(kuma::KMError)
16: kuma::SocketBase::ioReady(unsigned int, void*, unsigned long)
../../bin/linux/libkuma.so(+0x106cd2) [0x7f14752dacd2]
../../bin/linux/libkuma.so(+0x1094cc) [0x7f14752dd4cc]
19: std::function<void (unsigned int, void*, unsigned long)>::operator()(unsigned int, void*, unsigned long) const
20: kuma::EPoll::wait(unsigned int)
21: kuma::EventLoop::Impl::loopOnce(unsigned int)
22: kuma::EventLoop::Impl::loop(unsigned int)
23: kuma::EventLoop::loop(unsigned int)
./server() [0x4095e6]
./server() [0x4093e7]
./server() [0x40b442]
./server() [0x40b3ab]
./server() [0x40b34a]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x90c30) [0x7f1474b30c30]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x8182) [0x7f1474fbe182]
31: clone

why ./server() can not show the function ? even I add -rdynamic g++ param in test/server/MakeFile?
can you tell me?
thanks !

SSL_ERROR

I have obtained the certificate of www.baidu.com (mv baidu.com.cer ca.pem)
but the error in the figure still appears
image

buildRequestHeaders didn't make path well.

H2StreamProxy.cpp : buildRequestHeaders()
The git old version discard the path part, so that I get 400 bad request.
------from----------
std::string path = uri_.getPath();
if(!uri_.getQuery().empty()) {
path = "?" + uri_.getQuery();
}
if(!uri_.getFragment().empty()) {
path = "#" + uri_.getFragment();
}
--------to--------
std::string path = uri_.getPath();
if(!uri_.getQuery().empty()) {
path += "?";
path += uri_.getQuery();
}
if(!uri_.getFragment().empty()) {
path += "#";
path += uri_.getFragment();
}

A bug in kuma/src/http/Uri.cpp ?

line 42, Uri::parse function,I used it to parse url such as "ws://192.168.20.105:9326?token=android" , the variable query_ is empty string.

A bug in src/ws/WSHandler.cpp

src/ws/WSHandler.cpp,line 174、199, if len == pos,data[pos++] will be out of bounds , and the variate ctx_.hdr.xpl.xpl16 will be set wrong value.

Support Quic?

Hi,
I love kuma very much.

When do you suppose to support Quic?

Thanks

Stable status

Hi,
My question is how stable this library?
With regards

No Luck compiling with OpenSSL

I use:

  • GCC 6.3.0
  • OpenSSL 1.1.0k

When the Option KUMA_HAS_OPENSSL is turned on I run into error:
In file included from ssl/SslHandler.cpp:27:0: ./../vendor/openssl/include/openssl/x509v3.h:155:1: error: expected constructor, destructor, or type conversion before ‘typedef’ typedef BIT_STRING_BITNAME ENUMERATED_NAMES; ^~~~~~~ ./../vendor/openssl/include/openssl/x509v3.h:221:1: error: expected constructor, destructor, or type conversion before ‘DECLARE_ASN1_SET_OF’ DECLARE_ASN1_SET_OF(GENERAL_NAME) ^~~~~~~~~~~~~~~~~~~ ssl/SslHandler.cpp:124:1: error: expected ‘}’ at end of input } ^ Makefile:93: recipe for target '../objs/linux/ssl/SslHandler.o' failed make: *** [../objs/linux/ssl/SslHandler.o] Error 1

Help needed pls:

  • compiler used
  • OpenSSL version etc

http/2.0 testing connection reuse ...request failed..

hi,
i tryed test http/2.0 request in connection reuse case...

first request has success..
but second request has failed..

HttpRequest::Impl::sendRequest() return -2 ( INVALID_STATE )
code is IDLE or WAIT_FOR_REUSE case success ... current state::COMPLETE ...

what' wrong??

make android lib error

-- Build files have been written to: /root/code/kuma/bld/android/out/armeabi-v7a
[ 1%] Building CXX object CMakeFiles/kuma.dir/src/AcceptorBase.cpp.o
[ 2%] Building CXX object CMakeFiles/kuma.dir/src/DnsResolver.cpp.o
[ 4%] Building CXX object CMakeFiles/kuma.dir/src/SocketBase.cpp.o
[ 5%] Building CXX object CMakeFiles/kuma.dir/src/TcpConnection.cpp.o
[ 7%] Building CXX object CMakeFiles/kuma.dir/src/TcpListenerImpl.cpp.o
[ 8%] Building CXX object CMakeFiles/kuma.dir/src/TcpSocketImpl.cpp.o
[ 10%] Building CXX object CMakeFiles/kuma.dir/src/UdpSocketBase.cpp.o
[ 11%] Building CXX object CMakeFiles/kuma.dir/src/UdpSocketImpl.cpp.o
[ 13%] Building CXX object CMakeFiles/kuma.dir/src/compr/compr.cpp.o
[ 14%] Building CXX object CMakeFiles/kuma.dir/src/compr/compr_zlib.cpp.o
[ 16%] Building CXX object CMakeFiles/kuma.dir/src/http/H1xStream.cpp.o
[ 17%] Building CXX object CMakeFiles/kuma.dir/src/http/Http1xRequest.cpp.o
[ 19%] Building CXX object CMakeFiles/kuma.dir/src/http/Http1xResponse.cpp.o
[ 20%] Building CXX object CMakeFiles/kuma.dir/src/http/HttpCache.cpp.o
[ 22%] Building CXX object CMakeFiles/kuma.dir/src/http/HttpHeader.cpp.o
[ 23%] Building CXX object CMakeFiles/kuma.dir/src/http/HttpMessage.cpp.o
[ 25%] Building CXX object CMakeFiles/kuma.dir/src/http/HttpParserImpl.cpp.o
[ 26%] Building CXX object CMakeFiles/kuma.dir/src/http/HttpRequestImpl.cpp.o
[ 28%] Building CXX object CMakeFiles/kuma.dir/src/http/HttpResponseImpl.cpp.o
[ 29%] Building CXX object CMakeFiles/kuma.dir/src/http/Uri.cpp.o
[ 31%] Building CXX object CMakeFiles/kuma.dir/src/http/httputils.cpp.o
[ 32%] Building CXX object CMakeFiles/kuma.dir/src/http/v2/FlowControl.cpp.o
[ 34%] Building CXX object CMakeFiles/kuma.dir/src/http/v2/FrameParser.cpp.o
[ 35%] Building CXX object CMakeFiles/kuma.dir/src/http/v2/H2ConnectionImpl.cpp.o
[ 37%] Building CXX object CMakeFiles/kuma.dir/src/http/v2/H2ConnectionMgr.cpp.o
[ 38%] Building CXX object CMakeFiles/kuma.dir/src/http/v2/H2Frame.cpp.o
[ 40%] Building CXX object CMakeFiles/kuma.dir/src/http/v2/H2Handshake.cpp.o
[ 41%] Building CXX object CMakeFiles/kuma.dir/src/http/v2/H2Stream.cpp.o
[ 43%] Building CXX object CMakeFiles/kuma.dir/src/http/v2/H2StreamProxy.cpp.o
[ 44%] Building CXX object CMakeFiles/kuma.dir/src/http/v2/Http2Request.cpp.o
[ 46%] Building CXX object CMakeFiles/kuma.dir/src/http/v2/Http2Response.cpp.o
[ 47%] Building CXX object CMakeFiles/kuma.dir/src/http/v2/PushClient.cpp.o
[ 49%] Building CXX object CMakeFiles/kuma.dir/src/http/v2/h2utils.cpp.o
[ 50%] Building CXX object CMakeFiles/kuma.dir/src/kmapi.cpp.o
[ 52%] Building CXX object CMakeFiles/kuma.dir/src/proxy/BasicAuthenticator.cpp.o
[ 53%] Building CXX object CMakeFiles/kuma.dir/src/proxy/ProxyAuthenticator.cpp.o
[ 55%] Building CXX object CMakeFiles/kuma.dir/src/proxy/ProxyConnectionImpl.cpp.o
[ 56%] Building CXX object CMakeFiles/kuma.dir/src/utils/base64.cpp.o
[ 58%] Building CXX object CMakeFiles/kuma.dir/src/utils/utils.cpp.o
[ 59%] Building CXX object CMakeFiles/kuma.dir/src/ws/WSConnection.cpp.o
[ 61%] Building CXX object CMakeFiles/kuma.dir/src/ws/WSConnection_v1.cpp.o
[ 62%] Building CXX object CMakeFiles/kuma.dir/src/ws/WSConnection_v2.cpp.o
[ 64%] Building CXX object CMakeFiles/kuma.dir/src/ws/WSHandler.cpp.o
[ 65%] Building CXX object CMakeFiles/kuma.dir/src/ws/WebSocketImpl.cpp.o
[ 67%] Building CXX object CMakeFiles/kuma.dir/src/ws/exts/ExtensionHandler.cpp.o
[ 68%] Building CXX object CMakeFiles/kuma.dir/src/ws/exts/PMCE_Base.cpp.o
[ 70%] Building CXX object CMakeFiles/kuma.dir/src/ws/exts/PMCE_Deflate.cpp.o
[ 71%] Building CXX object CMakeFiles/kuma.dir/src/ws/exts/WSExtension.cpp.o
[ 73%] Building C object CMakeFiles/kuma.dir/third_party/zlib/adler32.c.o
[ 74%] Building C object CMakeFiles/kuma.dir/third_party/zlib/compress.c.o
[ 76%] Building C object CMakeFiles/kuma.dir/third_party/zlib/crc32.c.o
[ 77%] Building C object CMakeFiles/kuma.dir/third_party/zlib/deflate.c.o
[ 79%] Building C object CMakeFiles/kuma.dir/third_party/zlib/infback.c.o
[ 80%] Building C object CMakeFiles/kuma.dir/third_party/zlib/inffast.c.o
[ 82%] Building C object CMakeFiles/kuma.dir/third_party/zlib/inflate.c.o
[ 83%] Building C object CMakeFiles/kuma.dir/third_party/zlib/inftrees.c.o
[ 85%] Building C object CMakeFiles/kuma.dir/third_party/zlib/trees.c.o
[ 86%] Building C object CMakeFiles/kuma.dir/third_party/zlib/uncompr.c.o
[ 88%] Building C object CMakeFiles/kuma.dir/third_party/zlib/zutil.c.o
[ 89%] Building CXX object CMakeFiles/kuma.dir/third_party/HPacker/src/HPackTable.cpp.o
[ 91%] Building CXX object CMakeFiles/kuma.dir/third_party/HPacker/src/HPacker.cpp.o
[ 92%] Building CXX object CMakeFiles/kuma.dir/src/ssl/BioHandler.cpp.o
[ 94%] Building CXX object CMakeFiles/kuma.dir/src/ssl/OpenSslLib.cpp.o
[ 95%] Building CXX object CMakeFiles/kuma.dir/src/ssl/SioHandler.cpp.o
[ 97%] Building CXX object CMakeFiles/kuma.dir/src/ssl/SslHandler.cpp.o
[ 98%] Building CXX object CMakeFiles/kuma.dir/src/ssl/ssl_utils_linux.cpp.o
[100%] Linking CXX shared library ../../../../bin/android/armeabi-v7a/libkuma.so
ld: error: relocation R_ARM_REL32 cannot be used against symbol 'kev::KMObject::KMObject()::s_objIdSeed'; recompile with -fPIC

defined in CMakeFiles/kuma.dir/src/AcceptorBase.cpp.o
referenced by EventLoopImpl.cpp
EventLoopImpl.cpp.o:(kev::EventLoop::Impl::Impl(kev::PollType)) in archive /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a

ld: error: relocation R_ARM_REL32 cannot be used against symbol 'construction vtable for std::__ndk1::basic_istream<char, std::__ndk1::char_traits >-in-std::__ndk1::basic_stringstream<char, std::__ndk1::char_traits, std::__ndk1::allocator >'; recompile with -fPIC

defined in CMakeFiles/kuma.dir/src/AcceptorBase.cpp.o
referenced by EventLoopImpl.cpp
EventLoopImpl.cpp.o:(kev::EventLoop::Impl::Impl(kev::PollType)) in archive /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a

ld: error: relocation R_ARM_REL32 cannot be used against symbol 'vtable for std::__ndk1::basic_stringstream<char, std::__ndk1::char_traits, std::__ndk1::allocator >'; recompile with -fPIC

defined in CMakeFiles/kuma.dir/src/AcceptorBase.cpp.o
referenced by EventLoopImpl.cpp
EventLoopImpl.cpp.o:(kev::EventLoop::Impl::Impl(kev::PollType)) in archive /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a

ld: error: relocation R_ARM_REL32 cannot be used against symbol 'vtable for std::__ndk1::__shared_ptr_pointer<kev::TimerManager*, std::__ndk1::default_deletekev::TimerManager, std::__ndk1::allocatorkev::TimerManager >'; recompile with -fPIC

defined in /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a(EventLoopImpl.cpp.o)
referenced by EventLoopImpl.cpp
EventLoopImpl.cpp.o:(kev::EventLoop::Impl::Impl(kev::PollType)) in archive /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a

ld: error: relocation R_ARM_REL32 cannot be used against symbol 'vtable for std::__ndk1::basic_stringbuf<char, std::__ndk1::char_traits, std::__ndk1::allocator >'; recompile with -fPIC

defined in CMakeFiles/kuma.dir/src/AcceptorBase.cpp.o
referenced by EventLoopImpl.cpp
EventLoopImpl.cpp.o:(kev::EventLoop::Impl::Impl(kev::PollType)) in archive /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a

ld: error: relocation R_ARM_REL32 cannot be used against symbol 'VTT for std::__ndk1::basic_stringstream<char, std::__ndk1::char_traits, std::__ndk1::allocator >'; recompile with -fPIC

defined in CMakeFiles/kuma.dir/src/AcceptorBase.cpp.o
referenced by EventLoopImpl.cpp
EventLoopImpl.cpp.o:(kev::EventLoop::Impl::Impl(kev::PollType)) in archive /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a

ld: error: relocation R_ARM_REL32 cannot be used against symbol 'VTT for std::__ndk1::basic_stringstream<char, std::__ndk1::char_traits, std::__ndk1::allocator >'; recompile with -fPIC

defined in CMakeFiles/kuma.dir/src/AcceptorBase.cpp.o
referenced by EventLoopImpl.cpp
EventLoopImpl.cpp.o:(kev::EventLoop::Impl::Impl(kev::PollType)) in archive /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a

ld: error: relocation R_ARM_REL32 cannot be used against symbol 'vtable for std::__ndk1::__shared_ptr_emplace<kev::DLQueue<std::__ndk1::function<void (kev::LoopActivity)> >::DLNode, std::__ndk1::allocator<kev::DLQueue<std::__ndk1::function<void (kev::LoopActivity)> >::DLNode> >'; recompile with -fPIC

defined in /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a(EventLoopImpl.cpp.o)
referenced by EventLoopImpl.cpp
EventLoopImpl.cpp.o:(std::__ndk1::shared_ptr<kev::DLQueue<std::__ndk1::function<void (kev::LoopActivity)> >::DLNode> kev::DLQueue<std::__ndk1::function<void (kev::LoopActivity)> >::enqueue<std::__ndk1::function<void (kev::LoopActivity)> >(std::__ndk1::function<void (kev::LoopActivity)>&&)) in archive /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a

ld: error: relocation R_ARM_REL32 cannot be used against symbol 'construction vtable for std::__ndk1::basic_ostream<char, std::__ndk1::char_traits >-in-std::__ndk1::basic_ostringstream<char, std::__ndk1::char_traits, std::__ndk1::allocator >'; recompile with -fPIC

defined in CMakeFiles/kuma.dir/src/AcceptorBase.cpp.o
referenced by EventLoopImpl.cpp
EventLoopImpl.cpp.o:(kev::EventLoop::Impl::loop(unsigned int)) in archive /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a

ld: error: relocation R_ARM_REL32 cannot be used against symbol 'vtable for std::__ndk1::basic_ostringstream<char, std::__ndk1::char_traits, std::__ndk1::allocator >'; recompile with -fPIC

defined in CMakeFiles/kuma.dir/src/AcceptorBase.cpp.o
referenced by EventLoopImpl.cpp
EventLoopImpl.cpp.o:(kev::EventLoop::Impl::loop(unsigned int)) in archive /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a

ld: error: relocation R_ARM_REL32 cannot be used against symbol 'vtable for std::__ndk1::basic_stringbuf<char, std::__ndk1::char_traits, std::__ndk1::allocator >'; recompile with -fPIC

defined in CMakeFiles/kuma.dir/src/AcceptorBase.cpp.o
referenced by EventLoopImpl.cpp
EventLoopImpl.cpp.o:(kev::EventLoop::Impl::loop(unsigned int)) in archive /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a

ld: error: relocation R_ARM_REL32 cannot be used against symbol 'VTT for std::__ndk1::basic_ostringstream<char, std::__ndk1::char_traits, std::__ndk1::allocator >'; recompile with -fPIC

defined in CMakeFiles/kuma.dir/src/AcceptorBase.cpp.o
referenced by EventLoopImpl.cpp
EventLoopImpl.cpp.o:(kev::EventLoop::Impl::loop(unsigned int)) in archive /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a

ld: error: relocation R_ARM_REL32 cannot be used against symbol 'VTT for std::__ndk1::basic_ostringstream<char, std::__ndk1::char_traits, std::__ndk1::allocator >'; recompile with -fPIC

defined in CMakeFiles/kuma.dir/src/AcceptorBase.cpp.o
referenced by EventLoopImpl.cpp
EventLoopImpl.cpp.o:(kev::EventLoop::Impl::loop(unsigned int)) in archive /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a

ld: error: relocation R_ARM_REL32 cannot be used against symbol 'vtable for std::__ndk1::__shared_ptr_emplace<kev::TokenTaskSlot, std::__ndk1::allocatorkev::TokenTaskSlot >'; recompile with -fPIC

defined in /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a(EventLoopImpl.cpp.o)
referenced by EventLoopImpl.cpp
EventLoopImpl.cpp.o:(kev::EventLoop::Impl::appendTask(std::__ndk1::function<void ()>, kev::EventLoop::Token::Impl*, char const*)) in archive /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a

ld: error: relocation R_ARM_REL32 cannot be used against symbol 'vtable for kev::TaskSlot'; recompile with -fPIC

defined in /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a(EventLoopImpl.cpp.o)
referenced by EventLoopImpl.cpp
EventLoopImpl.cpp.o:(kev::EventLoop::Impl::appendTask(std::__ndk1::function<void ()>, kev::EventLoop::Token::Impl*, char const*)) in archive /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a

ld: error: relocation R_ARM_REL32 cannot be used against symbol 'vtable for kev::TokenTaskSlot'; recompile with -fPIC

defined in /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a(EventLoopImpl.cpp.o)
referenced by EventLoopImpl.cpp
EventLoopImpl.cpp.o:(kev::EventLoop::Impl::appendTask(std::__ndk1::function<void ()>, kev::EventLoop::Token::Impl*, char const*)) in archive /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a

ld: error: relocation R_ARM_REL32 cannot be used against symbol 'vtable for std::__ndk1::__shared_ptr_emplace<kev::TaskSlot, std::__ndk1::allocatorkev::TaskSlot >'; recompile with -fPIC

defined in /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a(EventLoopImpl.cpp.o)
referenced by EventLoopImpl.cpp
EventLoopImpl.cpp.o:(kev::EventLoop::Impl::appendTask(std::__ndk1::function<void ()>, kev::EventLoop::Token::Impl*, char const*)) in archive /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a

ld: error: relocation R_ARM_REL32 cannot be used against symbol 'vtable for kev::TaskSlot'; recompile with -fPIC

defined in /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a(EventLoopImpl.cpp.o)
referenced by EventLoopImpl.cpp
EventLoopImpl.cpp.o:(kev::EventLoop::Impl::appendTask(std::__ndk1::function<void ()>, kev::EventLoop::Token::Impl*, char const*)) in archive /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a

ld: error: relocation R_ARM_REL32 cannot be used against symbol 'vtable for std::__ndk1::__shared_ptr_emplace<kev::DelayedTaskSlot, std::__ndk1::allocatorkev::DelayedTaskSlot >'; recompile with -fPIC

defined in /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a(EventLoopImpl.cpp.o)
referenced by EventLoopImpl.cpp
EventLoopImpl.cpp.o:(kev::EventLoop::Impl::appendDelayedTask(unsigned int, std::__ndk1::function<void ()>, kev::EventLoop::Token::Impl*, char const*)) in archive /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a

ld: error: relocation R_ARM_REL32 cannot be used against symbol 'vtable for kev::TaskSlot'; recompile with -fPIC

defined in /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a(EventLoopImpl.cpp.o)
referenced by EventLoopImpl.cpp
EventLoopImpl.cpp.o:(kev::DelayedTaskSlot::DelayedTaskSlot(kev::EventLoop::Impl*, std::__ndk1::function<void ()>&&, std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >)) in archive /root/code/kuma/third_party/libkev/lib/android/armeabi-v7a/libkev.a

ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [../../../../bin/android/armeabi-v7a/libkuma.so] 错误 1
make[1]: *** [CMakeFiles/kuma.dir/all] 错误 2

x86 support

How can i compile this project to support android x86 or any other abi for that matter.
I tried generating openssl libs for x86 and put it in vendor folder however it did not work.
It keeps on giving errors like undefined references to few BIO_* and X503_*

it seems that no way to set Http2 connection with timeout

while TcpSocket::Impl::connect has timeout_ms arg,
but TcpConnection didn't pass this arg.

close() outside seems useless when connecting.

    // http is kuma::HttpRequest
    std::function<void()> fReconnect = [&] {
        puts("Reconnect");
        http.close();
        http.sendRequest("GET", "https://xxxxxxxxxxxx/");
        timerReconnect.schedule(1000, Timer::Mode::ONE_SHOT, fReconnect);
    };
    timerReconnect.schedule(1000, Timer::Mode::ONE_SHOT, fReconnect);

I had to insert this code into SocketBase::connect

    if (timeout_ms == 0)
        timeout_ms = 100;

and then it seems better to quick reconnect.

websocket client can't connect to the server on window

log:
INFO [19904] IocpSocket_6:: connect, host=192.168.124.6, port=8183
INFO [19904] IocpPoll::registerFd, fd=748, events=7
INFO [19904] IocpSocket_6:: connect_i, fd=748, local_ip=0.0.0.0, local_port=12431, state=2
INFO [6760] DNS resolving thread exited
INFO [21288] IocpSocket_6:: onConnect, err=0, state=2
INFO [21288] TcpSocket_5:: onConnect, err=0
INFO [21288] H1xStream_4:: onHttpEvent, ev=0
WARN [21288] IocpSocket_6:: onReceive, io_size=0, state=3, pending=0
INFO [21288] IocpSocket_6:: onClose, err=-12, state=3

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.