Supporting IPv6-only Networks

Supporting IPv6-only Networks
0.0 0

#21

@zhangxm

After adding #include "external/websockets/include/ios/libwebsockets.h" to WebSocket.h, i can build libjscocos2d.

But new errors occur when running cocos gen-libs

/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:473:16: error: out-of-line definition of
      'onSocketCallback' does not match any declaration in 'cocos2d::network::WebSocket'
int WebSocket::onSocketCallback(struct lws *wsi,
               ^~~~~~~~~~~~~~~~
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:562:23: error: assigning to
      'enum lws_write_protocol' from incompatible type 'int'
                                                                writeProtocol |= LWS_WRITE_NO_FIN;
                                                                              ^  ~~~~~~~~~~~~~~~~
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:568:41: error: assigning to
      'enum lws_write_protocol' from incompatible type 'int'
                                        writeProtocol |= LWS_WRITE_NO_FIN;
                                                      ^  ~~~~~~~~~~~~~~~~
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:642:44: error: use of undeclared identifier
      'libwebsockets_remaining_packet_payload'; did you mean 'lws_remaining_packet_payload'?
                    _pendingFrameDataLen = libwebsockets_remaining_packet_payload (wsi);
                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                           lws_remaining_packet_payload
In file included from /Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:30:
In file included from /Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.h:45:
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/build/../external/websockets/include/ios/libwebsockets.h:1613:1: note: 
      'lws_remaining_packet_payload' declared here
lws_remaining_packet_payload(struct lws *wsi);
^
4 errors generated.

It there any guide on how to solve IPv6 for Cocos2d-JS v3.8.1?


#22

@Zinitter I think you need to re-generate binding codes by run cocos2dx_root/tools/tojs/genbindings.py. And you can refer to this repo to set up environment if you meet any problem.


#23

@zhangxm

I have run genbindings.py but the issue still occur.

Generating javascript bindings succeeds 

I think there is issue on the manual bindings on path
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp

which won’t auto generated by the script.


#24

@zhangxm

Latest problem,

If i add #include "external/websockets/include/ios/libwebsockets.h" in WebSocket.h
I get this error :

/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:471:16: error: out-of-line definition of 'onSocketCallback' does not match any declaration in 'cocos2d::network::WebSocket'
int WebSocket::onSocketCallback(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, ssize_t len)

If i remove that #include,
I get this error :

/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/scripting/lua-bindings/proj.ios_mac/../../../network/WebSocket.h:152:60: error: ISO C++ forbids
      forward references to 'enum' types
        virtual int onSocketCallback(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len);

#25

@Zinitter If you want to build for cpp, lua and JSB, then you should:

  • fix compiling error of WebSocket.cpp/.h
    It seems you have done.
  • update binding codes of JSB and lua
  • fix compiling error by manually binding codes
    I think it is the same as fixing WebSocket.cpp/.h

#26

@zhangxm

Thank you for your guide.

I have success rebuild the cocos library with Cocos2d-JS v3.8.1.
I don’t need to add #include "external/websockets/include/ios/libwebsockets.h" in WebSocket.h

There is some mistakes on your v2 guide that caused the problem.
We can’t use the enum lws_callback_reasons instead of int reason but not sure why.

In WebSocket.h

Change this

int onSocketCallback(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len);

to this

int onSocketCallback(struct lws *wsi, int reason, void *user, void *in, ssize_t len);

In WebSocket.cpp

This is correct on the wrapper.

class WebSocketCallbackWrapper {
public:
    
    static int onSocketCallback(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len)

Change this

int WebSocket::onSocketCallback(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len)

to this

int WebSocket::onSocketCallback(struct lws *wsi, int reason, void *user, void *in, ssize_t len)

Is there any other way to test IPv6-only Networks besides the solution provided by Apple on app?
Because my internet connection is connected through wifi.

Thank you.


#27

@Zinitter may be the modification for v2 is not suitable for v3, it is just a reference. I don’t know if there is other way to test IPv6-only network.


#28

@zhangxm

There is slightly different on v3.

However, i noticed the onSocketCallback on v3.11.1 is still using int reason instead of enum lws_callback_reasons reason.

But why v2 need to use enum lws_callback_reasons reason?

I have post the modification on GitHub issue.

May be they can help test if it’s working as they having the same issue.

Updated :
How can i test if the WebSocket or curl modification is working on IPv4?
Please update if you found any other way to test IPv6-only network.

Thank you.


#29

Am using cocos2dx 3.11 and the latest version of sdkbox. The app was rejected by the AppStore today for not supporting IPV6 network.
The partial crash dump is here:

Incident Identifier: 8A5C51FA-40D4-324072F
CrashReporter Key:   e728ee6ad6be765594d9cbe7
Hardware Model:      xxx
Process:             TinySeries-mobile [15941] 
Path:                /private/var/containers/Bundle/Application/F1F35A27-37A3-4991-B010-97268A79C6D7/TinySeries-mobile.app/TinySeries-mobile
Identifier:          com.dtg.game
Version:             1.03 (1.03)
Code Type:           ARM-64 (Native)
Parent Process:      launchd [1]

Date/Time: 2016-06-30 19:49:48.48 -0700
Launch Time: 2016-06-30 19:49:48.48 -0700
OS Version: iOS 9.3.2 (13F69)
Report Version: 105

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000
Triggered by Thread: 0

Filtered syslog:
None found

Breadcrumb Trail: (reverse chronological seconds)
0 GC Framework: startAuthenticationForExistingPrimaryPlayer

Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 TinySeries-mobile 0x0000000100021cc8 0x100018000 + 40136
1 TinySeries-mobile 0x0000000100023794 0x100018000 + 46996
2 TinySeries-mobile 0x0000000100021b80 0x100018000 + 39808
3 TinySeries-mobile 0x0000000100021004 0x100018000 + 36868
4 TinySeries-mobile 0x00000001000380d8 0x100018000 + 131288
5 TinySeries-mobile 0x0000000100023acc 0x100018000 + 47820
6 UIKit 0x0000000187f4e9c0 0x187ec4000 + 567744
7 UIKit 0x000000018817e184 0x187ec4000 + 2859396
8 UIKit 0x00000001881825f0 0x187ec4000 + 2876912
9 UIKit 0x000000018817f764 0x187ec4000 + 2864996
10 FrontBoardServices 0x00000001847237ac 0x1846fc000 + 161708
11 FrontBoardServices 0x0000000184723618 0x1846fc000 + 161304
12 FrontBoardServices 0x00000001847239c8 0x1846fc000 + 162248
13 CoreFoundation 0x0000000182d3909c 0x182c58000 + 921756
14 CoreFoundation 0x0000000182d38b30 0x182c58000 + 920368
15 CoreFoundation 0x0000000182d36830 0x182c58000 + 911408
16 CoreFoundation 0x0000000182c60c50 0x182c58000 + 35920
17 UIKit 0x0000000187f4794c 0x187ec4000 + 538956
18 UIKit 0x0000000187f42088 0x187ec4000 + 516232
19 TinySeries-mobile 0x000000010002a7a8 0x100018000 + 75688
20 libdyld.dylib 0x00000001827fe8b8 0x1827fc000 + 10424

Activity ID: 0x0000000000139f8c
Activity Name: starting resolver activity
Activity Image Path: /usr/lib/system/libsystem_network.dylib
Activity Image UUID: A8E4200A-ECC7-3E56-A845-8A0E9CB4A6F0
Activity Offset: 0x0003333c
Activity Running Time: 0.240190 sec

Trace Messages (reverse chronological seconds):
0.136333 GameCenterFoundation 0x000000021383dda8 Format not found
0.144108 GameCenterFoundation 0x0000000190e62024 authenticateWithCompletionHandler:Username and Password passed in. GKDaemonProxy to authenticate player
0.146522 CFNetwork 0x0000000205d29da8 Format not found
0.146559 CFNetwork 0x000000018340951c TCP Conn 0x12dd87f70 started
0.148074 CFNetwork 0x0000000205d29da8 Format not found
0.156806 CFNetwork 0x0000000205d29da8 Format not found
0.175079 CFNetwork 0x0000000205d29da8 Format not found
0.176024 CFNetwork 0x0000000205d29da8 Format not found
0.176066 CFNetwork 0x000000018340951c TCP Conn 0x12dd6c550 started
0.179893 CFNetwork 0x0000000183463e5c Creating default cookie storage with default identifier
0.179893 CFNetwork 0x0000000183463e28 Faulting in CFHTTPCookieStorage singleton
0.181395 CFNetwork 0x00000001834b5e50 Faulting in NSHTTPCookieStorage singleton
0.237853 libsystem_network.dylib 0x0000000205355da8 Format not found
0.238738 libsystem_network.dylib 0x0000000205355da8 Format not found


#30

From the log, it seems the issue caused by libsystem_network.dylib. cocos2d-x doesn’t use this lib, so please make sure if there is another 3rd party library that uses this library.


#31

Could it be due to the game center call? I am using SDKBOX Play for game center support.

There is no other library.


#32

We need to ask @nite to help us with this.


#33

Shouldn’t be releated to SDKBOX since we don’t use that library in any way.


#34

Ok then. Will need to investigate further and will let you know.


#35

So I checked the code again and removed references to all other SDKs. The game is now completely based on Cocos2dx and SDKBOX. The SDKBOX plug-ins installed are, Play, Chartboost, Vungle, Ads, Rating and Share.

There are no other 3rd party libraries. The app was rejected once again due to not supporting IPV6. Am not very good at reading the crash dump, but could it be a Game Center issue, which I have integrated using SDKBOX Play?


#36

@dbest10 Sorry, 3.11 doesn’t support IPv6. You should upgrade libwebsockets from last version of 3rd party library.


#37

@zhangxm - will try and let you know. Thanks for letting me know


#38

Replaced the files for libwebsockets and curl. Submitted the new build to app store and it still got rejected with the same details in the crash file.


#39

@dbest10 do you have other third party library uses network related codes? I tested with IPV6 environment and there is not problem.
@slackmoehrle do you know any other develop passes app store? Or can not send an app to app store to have a test?


#40

All other libraries now come from SDKBOX (same as those I mentioned earlier). There is no other network calls / libraries that the code needs.